右连接JPA查询无法获得准确的输出

时间:2017-08-29 05:59:41

标签: java mysql hibernate jpa

我在JPA

中遇到此查询的问题

员工表

id,....,location_id (id 1,2,3,4 assigned to location id 1)

EmployeeMaster表

id,.....,date, employee_id(employee_id 1 and 2 having records in this table)

JPA查询

select me,ms from EmployeeMaster ms right join ms.employee me where ms.date between ?2 and ?3 and me.location.id = ?4

输出

employeeMaster,employee1
employeeMaster,employee2

因为只有两名员工在日期之间的EmployeeMaster表中有记录

我希望输出像

employeeMaster,employee1
employeeMaster,employee2
null,employee3
null,employee4

请帮我解决这个问题

感谢。

1 个答案:

答案 0 :(得分:0)

而不是检索employeeMaster检索员工,您将获得结果。

相关问题