JPQL problems with JOIN FETCH on List<Entity> [message #1061964] |
Wed, 05 June 2013 07:41 |
F C Messages: 12 Registered: June 2013 |
Junior Member |
|
|
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. */
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?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03542 seconds