Skip to main content



      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 03:41 Go to next message
Eclipse UserFriend
Hi,
I use EclipseLink 2.4 and JPA 2.0.
I have the following entities:

@Entity
@Table(name = "EMPLOYERS")
public class Employer implements Serializable {
...
@Id
@Column(name="ID")
private String id;

private String name;

private String surname;

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

and

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

@ManyToOne
@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(employer.id) = ?1 ");

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

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 14:25 Go to previous messageGo to next message
Eclipse UserFriend
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 10:44 Go to previous message
Eclipse UserFriend
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?
Previous Topic:NamedQuery of name ... not found.
Next Topic:EclipseLink 1.x on JBoss 7
Goto Forum:
  


Current Time: Sat Jul 12 16:30:44 EDT 2025

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

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

Back to the top