I have two objects:
User : id: long, name: StringPlayer : id: long, owner: User, points: int
Now I want to select the user and the player associated with him in a single JPQL query. In SQL, I would do it like this:
SELECT u.*, p.* FROM User u LEFT JOIN Player p ON (p.owner_id = u.id) WHERE u.name = ...
My first instinct was to do this in JPQL
SELECT u, p FROM User u LEFT JOIN Player p ON (p.owner = u) WHERE u.name = ...
But I don't think the ON clause is supported in JPQL. However, I need this because User does not have a reference to Player (many things, except Player , can be tied to User ). How can I solve this problem?
java sql jpa entity jpql
Bart van heukelom
source share