HQL查询返回空结果集 [英] HQL query returning Empty Resultset

查看:198
本文介绍了HQL查询返回空结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆