Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPQL problems with JOIN FETCH on List<Entity>
JPQL problems with JOIN FETCH on List<Entity> [message #1061964] Wed, 05 June 2013 07:41 Go to next message
F C is currently offline F CFriend
Messages: 12
Registered: June 2013
Junior Member
I use EclipseLink 2.4 and JPA 2.0.
I have the following entities:

@Table(name = "EMPLOYERS")
public class Employer implements Serializable {
private String id;

private String name;

private String surname;

@OneToMany(mappedBy="employer", fetch=FetchType.EAGER)
private List<Employee> list;


@Table(name = "EMPLOYEES")
public class Employee implements Serializable {

@JoinColumn(name="ID", insertable=false, updatable=false)
private Employer employer;


Now, my jpql is:
StringBuilder query = new StringBuilder();
query.append("SELECT employer FROM Employer employer ");
query.append("JOIN FETCH employer.list list ");
query.append("WHERE ");
query.append("UPPER( = ?1 ");

So, the generated SQL query is:
/* Formatted on 2013/06/05 09:16 (Formatter Plus v4.8.Cool */
FROM employees t0, employees t2, employers t1
WHERE ( (UPPER ( = ?)
AND (( = AND ( =

So, i can't understand why in FROM clause table EMPLOYEES appears two times.
Can someone help me?
Re: JPQL problems with JOIN FETCH on List<Entity> [message #1062077 is a reply to message #1061964] Wed, 05 June 2013 18:25 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1296
Registered: July 2009
Senior Member
I can't tell from what was provided - are there any other Employer-Employee relationships? Is T0, T2 or both appearing in the select statement?
Re: JPQL problems with JOIN FETCH on List<Entity> [message #1062970 is a reply to message #1062077] Tue, 11 June 2013 14:44 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You define your tables as uppercase, but the SQL you included is lower case, so either this is not the real code you are using, or not the real SQL that was generated?

James : Wiki : Book : Blog : Twitter
Previous Topic:NamedQuery of name ... not found.
Next Topic:EclipseLink 1.x on JBoss 7
Goto Forum:

Current Time: Wed May 23 21:01:47 GMT 2018

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

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

Back to the top