Vishal Mittal
Vishal Mittal

Reputation: 41

Use LEFT JOIN between two table in HQL

I have two POJO classes. One is EmployeeTO and another one is AddressTO.

EmployeeTO has one variable with name EmployeeId and AddressTO also has one variable with name EmployeeId. I want to apply a left join between EmployeeTO's EmployeeId and AddressTO's EmployeeId using HQL.

I used the following query.

from EmployeeTO employeeTO LEFT JOIN AddressTO addressTO ON employeeTO .EmployeeId=addressTO.EmployeeId

But it shows an error:

line 1:139: unexpected token: ON

Upvotes: 3

Views: 406

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522817

There is no ON clause in an HQL join:

from EmployeeTO e
left join e.addressTO

This assumes that your Employee entity class has an AddressTO field called addressTO.

Upvotes: 4

Related Questions