Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy-loading doesn't work with Set #117

Open
jblaufuss opened this issue Sep 21, 2016 · 0 comments
Open

Lazy-loading doesn't work with Set #117

jblaufuss opened this issue Sep 21, 2016 · 0 comments

Comments

@jblaufuss
Copy link

jblaufuss commented 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 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).

@jblaufuss 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 mhgrove changed the title Lazy-loading doesn't work with Set (performance issue) Lazy-loading doesn't work with Set Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants