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: 45
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: 1275
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: 1275
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: 1275
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 get stuck
Next Topic:Report security Issue
Goto Forum:
  


Current Time: Thu Dec 14 13:27:46 GMT 2017

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

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