Hi Tom,
attached you find my fix for issue 2865 "JPQL: invalid SQL SELECT clause
for query joining the same relationship twice":
https://glassfish.dev.java.net/issues/show_bug.cgi?id=2867
I changed method ExpressionQueryMechanism.extractStatementFromItem() as
you proposed with a small update. I check for already cloned expressions
before doing a rebuild of the expression, but only if it is *not* an
ExpressionBuilder. With the original change I got a couple of test
failures in entity-persistence-test, because a getSingleResult query
returned more than one instance. The generated SQL included all the
tables twice which caused the single instance being included multiple
times in the query result.
You find the fix and new test cases attached. Please have a look.
Thanks!
Regards Michael