jpql, join on?
843830Mar 12 2010 — edited Mar 13 2010a simplified example:
i have two tables, dog and cat, there are not foreign key reference between them. i use openJPA to implement jpa mapping, and two entities are generated: Catty and Doggy. and there are not reference between these two objects too.
but in my app, i want to implement join query. something like following in NATIVE SQL:
select from dog d join cat c on d.age = c.age.*
it works on my db2.
so i use jpql like following:
SELECT d FROM Doggy d JOIN Catty c ON d.age = c.age.
unfortunately, the jpql throw exception. similar with following:
org.apache.openjpa.persistence.ArgumentException: Encountered "JOIN Catty c" at character xx, but expected: [".", "FETCH", "INNER", "JOIN", "LEFT", <IDENTIFIER>].
question:
1 what is the problem of my jpql?
2 while i use join in jpql, is it mandatory to define a reference attribute to other object in first object?
3 does jpql support "ON" key word. i have checked jpql manual, it seem it is not preserved?
thanks