Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to avoid additional sql query for nested left join
How to avoid additional sql query for nested left join [message #1733983] Thu, 02 June 2016 15:25 Go to next message
Pavel No is currently offline Pavel NoFriend
Messages: 47
Registered: May 2016
Member
I have the following entities:

@Entity
class A{
 @OneToMany
 private List<B> bs;
 ...
}

@Entity
class B{
 @OneToMany
 private List<C> cs;
 ...
}

@Entity
class C{
 ...
}


So I do the followin query:
SELECT a FROM A a LEFT JOIN FETCH a.bs b LEFT JOIN b.cs


This code works, the only problem that A and B are read from database in one join query, but for reading C (LEFT JOIN b.cs) separate sql query is executed to read only C entities. How to read A,B,C in one sql query.
Re: How to avoid additional sql query for nested left join [message #1734850 is a reply to message #1733983] Mon, 13 June 2016 13:46 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
JPQL doesn't support nesting fetch joins, so the only way to do this would be to use EclipseLink's "eclipselink.join-fetch" query hint: http://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/q_join_fetch.htm
Re: How to avoid additional sql query for nested left join [message #1734886 is a reply to message #1733983] Mon, 13 June 2016 13:46 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
JPQL doesn't support nesting fetch joins, so the only way to do this would be to use EclipseLink's "eclipselink.join-fetch" query hint: http://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/q_join_fetch.htm
Re: How to avoid additional sql query for nested left join [message #1734893 is a reply to message #1733983] Mon, 13 June 2016 13:46 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
JPQL doesn't support nesting fetch joins, so the only way to do this would be to use EclipseLink's "eclipselink.join-fetch" query hint: http://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/q_join_fetch.htm
Previous Topic:EclipseLink: weaving, inheritance - entities in different jar
Next Topic:Re: JPA: EntityGraph -&gt; FetchGroupException [CLOSED]
Goto Forum:
  


Current Time: Tue Apr 23 13:45:40 GMT 2024

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

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

Back to the top