Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Chain of eager relationships
Chain of eager relationships [message #606332] Tue, 21 September 2010 19:48 Go to next message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
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 13:49 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1294
Registered: July 2009
Senior Member

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,
Previous Topic:Problems to use order by a null association
Next Topic:OneToOne lazy relationship was already fetched?
Goto Forum:

Current Time: Fri Apr 20 01:31:48 GMT 2018

Powered by FUDForum. Page generated in 0.01763 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software