| When enhancing with enableAssociationManagement=true, collections are initialized when they're loaded making lazy loading not work. 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 "$$_hibernate_write_myLazyCollectionName(Set)" The implementation of "$$_hibernate_write_myLazyCollectionName(Set)" can be found at https://github.com/hibernate/hibernate-orm/blob/5.2.7/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/PersistentAttributesEnhancer.java#L410 - it calls org.hibernate.collection.internal.PersistentSet.toArray() which loads the (supposed to be lazy) persistentSet from the database. |