问题
I have a class where a few members have annotation:
@ManyToOne(fetch = FetchType.EAGER)
In the specific part of my program, these load far too many data. Unfortunately, I can't change these annotations as this will influence performance of other parts of this program. Is there a way in eclipselink to change this to LAZY for 1 specific JPQL query?
To phrase this an other way, you can change LAZY to EAGER by using a fetch join. I'm hoping for something which changes EAGER to LAZY
回答1:
It's not possible. My rule of thumb is : make everything LAZY, and use custom queries if you want eager fetching.
The best you can do is to load tuples (and populate DTOs) instead of loading entities.
回答2:
I know that since eclipselink 2.3 you can extend your entities at runtime, maybe check that? http://wiki.eclipse.org/EclipseLink/Examples/JPA/Extensibility
来源:https://stackoverflow.com/questions/7027707/jpa-and-eclipselink-overriding-fetchtype-eager