persistence@glassfish.java.net

JPQL: fix generated SQL for query mixing inner and outer joins (issue 3041)

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Mon, 04 Jun 2007 20:40:15 +0200

Hi Tom,

attached you find my fix for issue 3041"Invalid SQL generated when
mixing inner and outer joins":
https://glassfish.dev.java.net/issues/show_bug.cgi?id=3041

The JPQL query defines an inner join and three outer joins. The
generated SQL includes the correct clauses for the inner and outer
joins, but it places one of the outer join clauses in the wrong part of
the SQL FROM clause. This results into a SQLException at runtime.

I changed method appendFromClauseForOuterJoin in class
SQLSelectStatement. I reorder the outer join expression such that all
outer join expressions having the same source alias are processed
together. Then the generated SQL includes the outer join clause in the
correct order. You find the fix and a new entity-persistence-tests test
cases attached. Please have a look.

Thanks!

Regards Michael