JPA group by 和可为 Null 的字段
我的 jpa 有问题。 我正在使用 Criteria 创建一个查询,该查询必须返回使用适当的联接从多个表中检索的对象列表。问题是查询涉及的某些值可能为空。如果我不添加 group by 子句,一切都会正常工作,但如果我添加 group by 或 sum 之类的聚合函数,则空值不会出现在输出列表中。 真正奇怪的是,如果我将 hibernate 生成的查询放入 Toad 中,它会给出正确的结果列表。
提前致谢
I have a problem with jpa.
I'm creating a query using Criteria that have to return me a list of object retreived from multiple tables using appropriate joins. The problem is that some of the values involved with the query can be null. Everything works fine if I don't add the group by clause but if I add the group by or an aggregate function like sum, then the null values arent presente in the output list.
The thing that is really strange is that if I put the query generated by hibernate into Toad it gives me the correct result list.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NULL 值在 JPA 中大多被忽略,甚至在 SQL 中也是如此,请参阅 http://www.sqlsnippets。 com/en/topic-12656.html
NULL values are mostly ignored in JPA, even in SQL, see http://www.sqlsnippets.com/en/topic-12656.html