What if just one side is eager? Also, is the @OneToMany's mappedBy
attribute set up correctly?

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: David Wisneski [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, February 14, 2007 3:27 PM
> To: open-jpa-dev
> Subject: extraneous joins OPENJPA-134
> 
> 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