david wrote:
The new parser is much more picky (as it should be) with what can be passed through the SQL generator. If you want outer joins you need the relationship mapped or you can use nativeSQL. In your case that should be fine since you are using an Oracle extension to the HQL anyway.
OK, even if it doesn't solve the problem, at least this gives me a conclusive answer that what I want is not possible in HQL at this time. Maybe it would be possible (feature request) to allow it in one form or the other, e.g. to somehow add the variant I described above:
Code:
from A a left join B b on a.xx=b.xx where a.id=?
which is a ansi-style outer join from a to b.
"for the time being" I have solved it using two queries:
Code:
from A a where a.id=?
from A a, B b where a.id=? and a.xx=b.xx
I execute the 2nd query, store the result tuples a,b in a Map from A to B.
Then I execute the first query and for each A I make a lookup in the map from A to B and either I get a B or I get null. It is slower and more cumbersome than before, but at least it still works. In our case, we retrieve 1000s of A, making a loop and executing a query for each A to see if a B exists for it would be a performance killer.
To use native sql: I'll try that too, but if possible I'd like to avoid it.