HQL查询返回空结果集 [英] HQL query returning Empty Resultset
问题描述
我有这个 HQL查询,它返回一个空结果集:
FROM MeetingSchedule ms JOIN FETCH ms.client JOIN FETCH ms.employees JOIN FETCH ms.parts
WHERE ms.meetingId =:meetingId;
如果我执行 SQL查询给我结果
select * from meeting_schedule where meeting_id =?;
如何调试此查询?
空结果集的原因是什么?
$ b PS:
SQL查询只是为了告诉您我的 MeetingSchedule 不为空,我可以发布生成的 SQL查询这里如果你想。
先进的谢谢。
这些是2个不同的查询。在HQL中,你使用JOINS而不是SQL。对相同查询的结果进行比较。答案很简单 - 一些关系丢失会导致连接失败,排除给定的结果行。
您显示的SQL的等效值为
FROM MeetingSchedule ms WHERE ms.meetingId =:meetingId;
我敢打赌,结果不会为空。
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.
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.
这篇关于HQL查询返回空结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!