Suppose there is a Parent class and I load it using lazy = "true"
.
Is there a way to verify that the Set is not loaded in the memory before an explicit call is made for it?
public class Parent{
private Intger parentId;
Set <Child> child = new HashSet();
}
The child class:
public class Child{
private Integer childId;
Parent p;
}
When I load Parent, and before I call parent.getChild()
, is there a way to verify that the child is not loaded into the memory?
To test the application the following function was used:
Set<Child> childLazy = parentLazyLoaded.getChild();
Set<Child> childEager = parentEagerLoaded.getChild();
//then use the following methods
System.out.println("Lazy Loaded: " + Hibernate.isInitialized(childLazy));
System.out.println("Eager Loaded: " + Hibernate.isInitialized(childEager));
First one returns false
and the second one true
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.