hibernate - HQL 连接许多子句
我一直在阅读 Hibernate 文档,但没有找到任何可以解释如何执行以下操作的内容。
我有以下 SQL 代码,我试图将其转换为 HQL:
SELECT {msg.*}, {cmd.*}
FROM Schema.Messages AS msg
LEFT OUTER JOIN schema.send_commands AS cmd
ON cmd.message_key = msg.unique_key
AND ( lower(cmd.status) IN (lower('failed') ) )
WHERE msg.sequence_received < 10";
我遇到的主要问题是我无法在 LEFT OUTER JOIN 上有两个子句。 HQL 让我可以拥有 ON cmd.message_key = msg.unique_key
,但是我如何添加 AND 子句 2?
I've been reading Hibernate documentation, but I haven't found anything that would explain how to do the following.
I have the following SQL code that I'm trying to convert to HQL:
SELECT {msg.*}, {cmd.*}
FROM Schema.Messages AS msg
LEFT OUTER JOIN schema.send_commands AS cmd
ON cmd.message_key = msg.unique_key
AND ( lower(cmd.status) IN (lower('failed') ) )
WHERE msg.sequence_received < 10";
The mainissue I'm having is that I'm unable to have two clauses on a LEFT OUTER JOIN. HQL allows me to haveON cmd.message_key = msg.unique_key
, but how do I add theAND clause 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
with
关键字添加额外的连接条件,如下所示(取决于您的映射):另请参阅:
You can add extra join conditions using
with
keyword, something like this (depends on your mapping):See also: