NobesInd
NobesInd

Reputation: 97

HQL Query for simple SQL joins

how can i apply 2 conditions in join in HQL I want to write HQL for below query

Select * from Employee e
left join fetch Salary s on s.sal in (1000,2000);

My question is: how can we apply multiple conditions on join. i know internally, the query will be executed like

select * from Employee e
left join Salary s on s.id = e.id

but how can i write hql for more than single condition? I hope my question is cleared?

Upvotes: 2

Views: 250

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522712

A valid HQL query would look something like this:

select e, s 
from Employee e left join e.salary s with (s.sal in (1000,2000))

This assumes that the Employee entity has a Salary field salary. If I have the names off, then change the query.

Upvotes: 3

Related Questions