Hi Patrick or Abe,

I was wondering if any of you have noticed the following problem.  (
this is written up as OPENJPA-134).  This shows up as a performance
problem in applications when we compare with  Hibernate.

If I have a M:1 relationship and I make both sides of the relationship
EAGER in the mapping, OR  I do a  join fetch of the multi side
relationship,  we see an extra join in the generated sql.

Example:  I have a Dept -> Emp with inverse Emp->Dept.
If both sides are EAGER in mapping I get the sql

 select ..  from dept t0 join emp t1 on(...) join dept t2 on (...)

If both sides are LAZY and I do EJB query
 select  d from Dept d left join fetch d.emps

the generated sql is
 select ...  from dept t0 left join emp t1 on(...) join dept t2 on(...)

The extra  "join dept t2 on(...)" seems to be extraneous and has a
serious impact on performance.   Since I already joined Dept with Emp,
there is no need to join it back to the Dept because the Dept->Emp and
Emp->Dept relationships are inverses of the same foreign key.

Have you noticed this same problem?  Might you have a quick fix that
you can?  Otherwise we will start analyzing to see what might be
causing it.

Reply via email to