Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jpql, join on?

843830Mar 12 2010 — edited Mar 13 2010
a 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2010
Added on Mar 12 2010
3 comments
306 views