HQL query returning Empty Resultset

吃可爱长大的小学妹 提交于 2019-12-12 04:21:43

问题


I have this HQL query which returns me an Empty Resultset :

FROM MeetingSchedule ms JOIN FETCH ms.client JOIN FETCH ms.employees JOIN FETCH ms.parts 
WHERE ms.meetingId = :meetingId;

If I execute SQL Query gives me result

select * from meeting_schedule where meeting_id = ?;

How to debug this query?

What will be the cause for Empty Resultset ?

PS:

SQL Query is just to inform you that my MeetingSchedule is not null, I can post generated SQL Query here if you want.

Thank you in advanced.


回答1:


Those are 2 different queries. In HQL you are using JOINS while in SQL not. Do the comparision of results of EXACT the same queries. Answer is ratjher simple - some of relations are missing causing join to fail, excluding given row in result.

Equivalent of SQL you have shown is

FROM MeetingSchedule ms WHERE ms.meetingId = :meetingId;

I bet that result will not be empty.



来源:https://stackoverflow.com/questions/45103580/hql-query-returning-empty-resultset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!