When both sides of a relationhship are EAGER this should result in only one join (not two).
Account <-> Holidng is One Account has Many holdings. Both roles of the relationship are marked EAGER. If I join Account t0 join Holding t1 on(t1.account=t0.accountId) there should not be a need to do Account t0 join Holding t1 on(t1.account=t0.accountId) join Account t2 on(t2.accountid=t1.account) t2 would be the same values as t0. Putting in the extraneous join is not needed and we see performance degradation compared to other OR products (e.g. Hibernate). I think we can just not generate the extra join -- unless someone sees something that I don't see. On 2/15/07, catalina shaw <[EMAIL PROTECTED]> wrote:
Regardless the ManyToOne is EAGER by default, when its inverse relationship if 1. set to EAGER (select a from a a; a has the OneToManyRelation property) or 2. set to LAZY but Eagerly Fetched by query (select ... from a a join fetch a.OneToManyRelation ) We see unneeded joins being generated. The issue is why generating the extraneous joins that can be optimized away. >> I've looked at the code and it looks correct to me and tried various >> things like making the inverse LAZY. But it always generating the >> extraneous join. I've attached the entity source code. >> >> The relationship causing problem is >> >> @ManyToOne >> @JoinColumn(name="ACCOUNT_ACCOUNTID") >> private Accountejb2 account2; >ManyToOne is eager by default, so right now both sides are eager.