| When loading entities with POJO classes enhanced using hibernate-enhance-maven-plugin with this configuration:
all collections get initialized instantly although annotated with javax.persistence.FetchType.LAZY. Collection fields are first initialized with "new HashSet(0)" on POJO class instantiation. After that, the PojoEntityTuplizer sets an unitialized PersistentSet using the property setter. This leads to a call to "$$_hibernat_write_myLazyCollectionName(Set)" where the dirty tracking mechanism asks whether the HashSet and PersisntentSet instances are equal. Later on HashSet.equals(Object) calls PersisntentSet.size() where that PersisntentSet is now going to initialize itself. Each entry in the so initialized PersisntentSet will behave the same, leading to a fully loaded Entity graph at some point in time. I kept terminating the JVM after some minutes of loading. This is an example of a partial calling stack:
|