You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using Empire for the ORM layer of our application. We have several entities that have java.util.LinkedHashSet collections that are annotated to be lazy-loading with @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL), however we are observing these entities being eager-loaded in our application despite the annotation.
I have spent some time debugging this, and it appears this is due to the way Empire's javaassist proxies are interacting with the java.util.LinkedHashSet implementation: when the proxies are put into the LinkedHashSet's backing LinkedHashMap, the entity-proxy's hashCode() method is called (from HashMap.hash(Object)), which then triggers the ProxyHandler to load the actual entity data. This can happen recursively, causing an eager load of quite a lot of entities despite the consistent use of FetchType.LAZY.
We found this issue in the develop branch (we pulled it in sometime in early 2016).
The text was updated successfully, but these errors were encountered:
jblaufuss
changed the title
Lazy-loading doesn't work with java.util.HashSet (performance issue)
Lazy-loading doesn't work with Set (performance issue)
Sep 21, 2016
mhgrove
changed the title
Lazy-loading doesn't work with Set (performance issue)
Lazy-loading doesn't work with Set
Sep 21, 2016
We are using Empire for the ORM layer of our application. We have several entities that have
java.util.LinkedHashSet
collections that are annotated to be lazy-loading with@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
, however we are observing these entities being eager-loaded in our application despite the annotation.I have spent some time debugging this, and it appears this is due to the way Empire's javaassist proxies are interacting with the
java.util.LinkedHashSet
implementation: when the proxies areput
into the LinkedHashSet's backingLinkedHashMap
, the entity-proxy'shashCode()
method is called (fromHashMap.hash(Object)
), which then triggers theProxyHandler
to load the actual entity data. This can happen recursively, causing an eager load of quite a lot of entities despite the consistent use ofFetchType.LAZY
.We found this issue in the
develop
branch (we pulled it in sometime in early 2016).The text was updated successfully, but these errors were encountered: