Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何获取fetch=FetchType lazy注释的属性名称?_Java_Spring_Hibernate - Fatal编程技术网

Java 如何获取fetch=FetchType lazy注释的属性名称?

Java 如何获取fetch=FetchType lazy注释的属性名称?,java,spring,hibernate,Java,Spring,Hibernate,我想获得具有延迟获取类型注释的属性列表。我可以通过思考来做到这一点,并在手边阅读。不过,我想知道是否还有其他方法可以从ClassMetaData或perister获取惰性属性列表GetPropertyAziness没有返回正确的结果,getLazyProperties也没有返回正确的结果?类元数据的GetPropertyAziness方法应该返回正确的值 你有没有试过这样的方法: ClassMetadata meta = sessionFactory.getClassMetadata(entit

我想获得具有延迟获取类型注释的属性列表。我可以通过思考来做到这一点,并在手边阅读。不过,我想知道是否还有其他方法可以从
ClassMetaData
perister
获取惰性属性列表
GetPropertyAziness
没有返回正确的结果,getLazyProperties也没有返回正确的结果?

类元数据的
GetPropertyAziness
方法应该返回正确的值

你有没有试过这样的方法:

ClassMetadata meta = sessionFactory.getClassMetadata(entity.getClass());
String[] propertyNames = meta.getPropertyNames();
boolean[] propertyLaziness = meta.getPropertyLaziness();

for (int i = 0; i < propertyNames.length; i++) {
    String propertyName = propertyNames[i];

    // Check if the property fetch type is Lazy
    if (propertyLaziness[i]) {
        System.out.println("Property : " + propertyName + " fetch type is Lazy");
    }
}
ClassMetadata meta=sessionFactory.getClassMetadata(entity.getClass());
字符串[]propertyNames=meta.getPropertyNames();
布尔[]propertyLaziness=meta.getPropertyLaziness();
for(int i=0;i
我只是这样做了,但我看不出propertyLaziness是真的。我可以看出,在collectionMetaData中,他们是懒惰的。但是,从CollectionMetaData中,我无法让OneToOne懒惰,因为它们不是集合