3

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

hyperman
  • 1,324
  • 1
  • 11
  • 21

2 Answers2

2

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.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
0

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

Dorpsidioot
  • 474
  • 2
  • 7
  • This is scary stuff, maintenance-wise ;-) Even so, thanks for letting me know about this corener of eclipselink. One day it will be handy! – hyperman Aug 16 '11 at 07:28