[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Please help with @ManyToOne - left outer join
|
Hello Martin,
EclipseLink interpreted the specification to mean that it should use
inner joins where ever dot notation is used for a relationship unless
the relationship is defined explicitly to use an outer join. Bug 246211
exists for for this behavior:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=246211
Best Regards
Chris
Janda Martin wrote:
Maybe I found solution,
This doesn't work - still uses inner join
select object(o) from Company as o left join o.employee e order by o.employee.age asc
This WORKS - (difference is "e.age" instead of "o.employee.age")
select object(o) from Company as o left join o.employee e order by e.age asc
I have to specify left join instead of automatic outer join defined by annotations. Is this correct behaviour?
Thank you
Martin
----- Original Message -----
From: "Janda Martin" <jandam@xxxxxxxxxx>
To: "eclipselink-users" <eclipselink-users@xxxxxxxxxxx>
Sent: Sunday, February 21, 2010 11:43:01 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: [eclipselink-users] Please help with @ManyToOne - left outer join
Hello,
I have another question. I have @ManyToOne relationship (partial implementation)
@Table....
class Company {
@Id
@Column(name = "COMPANY", nullable = false)
private idCompany;
@JoinColumn(name = "ID_EMP", referencedColumnName = "ID_EMP")
@ManyToOne
@JoinFetch(value = JoinFetchType.OUTER)
private Employee employee;
...
}
@Table...
class Employee {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQ_EMP")
@Basic(optional = false)
@Column(name = "ID_EMP", nullable = false)
private int idEmp;
@Column(name = "AGE")
private double age;
....
}
I want to execute "select object(o) from Company as o order by o.employee.age asc". But the result doesn't return Companies with Company.employee = NULL. It has where condition with "=" not with outer join.
Please can you help me what I'm doing wrong. Platform: Derby 10.5.3.0, EclipseLink 1.1.3. Is it necessary to use EclipseLink 2.0.1? Or my definition is wrong. I tried to look in tests for eclipselink but I don't se any solution.
I need tell EclipseLink to use Left Outer Join for querying "employee".
I tried redefine mapping in DescriptorCustomizer for "Company" without success.
OneToOneMapping m = (OneToOneMapping) descriptor.getMappingForAttributeName("employee");
m.dontUseIndirection();
m.useOuterJoinFetch();
Thank you
Martin
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users