我们正在使用方法Persistence.getPersistenceUtil()。isLoaded,该方法调用方法PersistenceUtilHelper.isLoadedWithReference,在我们的示例中,我们有一个被覆盖的字段,并且在使用策略FieldAccess,但是下面的类PersistenceUtilHelper的代码没有从源类中获取字段。实际上,如果在当前实体中找不到该字段,它将调用getter方法(作为属性访问):catch catch NoSuchFieldException而不检查超级实体
private AttributeAccess buildAttributeAccess(final String attributeName) {
final PrivilegedAction<AttributeAccess> action = new PrivilegedAction<AttributeAccess>() {
@Override
public AttributeAccess run() {
for ( Class clazz : classHierarchy ) {
try {
final Field field = clazz.getDeclaredField( attributeName );
if ( field != null ) {
return new FieldAttributeAccess( field );
}
}
catch ( NoSuchFieldException e ) {
final Method method = getMethod( clazz, attributeName );
if ( method != null ) {
return new MethodAttributeAccess( attributeName, method );
}
}
}
//we could not find any match
return new NoSuchAttributeAccess( specifiedClass, attributeName );
}
};
return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run();
}
这是hibernate-entitymanager中的错误吗?