Skip to main content

[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:

Best Regards

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

----- 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


  I have another question. I have @ManyToOne relationship (partial implementation)

class Company {

  @Column(name = "COMPANY", nullable = false)
  private idCompany;

    @JoinColumn(name = "ID_EMP", referencedColumnName = "ID_EMP")
    @JoinFetch(value = JoinFetchType.OUTER)
  private Employee employee;


class Employee {
  @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, 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");

 Thank you
eclipselink-users mailing list
eclipselink-users mailing list

Back to the top