Chain of eager relationships [message #606332] |
Tue, 21 September 2010 15:48  |
Eclipse User |
|
|
|
If I have a chain of eager relationships ( A → B → C → D), if I find an instance of the entity A, I get the whole chained objects (A, Bs, Cs and Ds)
Is there a way to limit the number of levels to be fetched eagerly? For instance, I just want the B relationships (first level) should be fetched eagerly.
I'm working with eclipselink 1.2.1.
Thanks again. Mauro.
|
|
|
Re: Chain of eager relationships [message #628634 is a reply to message #606332] |
Thu, 23 September 2010 09:49  |
Eclipse User |
|
|
|
Hello,
Unfortunately there isn't a way in JPA other than using Lazy relations or fetch groups. When specifying eager relationships, you are saying that when you fetch Bs you always want to Fetch Cs, and when fetching Cs you always want Ds. It might be better to mark all relationships as lazy, and then fetch join the relationships required in the queries used to bring in the first level entities.
Fetch groups can also be used much like lazy relationships to only return what you want, and can be used at the query level to return levels different than the default settings - compariable to using join fetch.
Best Regards,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.04196 seconds