As described in HHH-10747 Closed lazy PersistentCollections still get initialized when dirtyCheck enhancement is added. HHH-11985 Open also suggests that this is not fully solved. I assume dirtyCheck enhancement purpose is to increase performance which fails when many lazy PersistentCollection are present. For extra lazy PersistentCollection, size() invocation triggers a query "SELECT count(id) from ... where ..." for every PersistentCollection attribute present in the entity class. General lazy PersistentCollections are fully initialized upon size() invocation. If entities in that collection have PersistentCollection typed attributes too, they also get initialized which ends up in hibernate wanting to load the entire tree of persisted entities into the heap. As commented here https://hibernate.atlassian.net/browse/HHH-11985?focusedCommentId=102468&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-102468 the root cause is that size() is invoked on entity initialization and used to determine if a collection is dirty or not. I guess PersistentCollection.isDirty() would perform better here. Additionally I fear the size based dirty check might fail to detect updates like this:
AnEntity e = session.get( AnEntity.class, entityId );
e.getChildren().add("a");
e.getChildren().remove("b");
I would like to provide a test case but so far I fail to get hibernate source properly imported into eclipse Neon. What is the preferred IDE you use to develop hibernate? "gradle eclipse" as suggested here https://github.com/hibernate/hibernate-orm/blob/master/README.md fails because there's no task "eclipse" |