GingerFish
GingerFish

Reputation: 478

How to convert a simple SQL join query to HQL

I have this query that I need in HQL, but I have found very little help online.

select first_name, last_name, group_id, group_name, status
from users
join groups on groups.id = users.group_id

What would this be if converted to HQL?

Upvotes: 0

Views: 588

Answers (1)

Bohemian
Bohemian

Reputation: 424983

Making a few assumptions:

select u.first_name, u.last_name, u.group.id, u.group.group_name, u.group.status
from users u

Basically the join is done for you. You just reference other objects in the object graph using dot notation.

Upvotes: 1

Related Questions