After writing a Java EE 5 app using Glassfish using JPA1.0 / EJB3.0, I had problems with some EJBQL queries. It turned out that navigating relations works different, than I suspected. My query string looked liked:
SELECT f FROM Foo f WHERE f.bar.fooBar LIKE '%abc%' OR f.baz > 0
f.baz > 0 always yields a TRUE for any f. So I assumed that I will get all instances of f. It turned out that my assumtion was wrong, because the "." operator has the semantics of an inner join and not the semantics of an outer join. So all instances of f, that had f.bar = NULL did not make it into the result list, although the second part od the OR condition was TRUE. Although this behaviour is correct according to the JPA spec, it turned out to be quite unexpected to me.
Now my questions:
a) Does anyone also encountered the same problem?
b) Can anyone tell me there are plans for JPA 2.0 to provide an additional navigation Operator that has outer join semantics? (This would be nice in my case where the query string is generated by a rather complicated transformation from an XML by concatenating the parts of the query string)
PS.: The working query string is
SELECT f FROM Foo f LEFT JOIN f.bar b WHERE b.fooBar LIKE '%abc%' OR f.baz > 0
Regards
Heiko
[Message sent by forum member 'hewagn00' (hewagn00)]
http://forums.java.net/jive/thread.jspa?messageID=263844