Hibernate Criteria Query 到外连接子查询结果
我需要将下面的 SQL 查询转换为条件查询。 只有一张表,请注意,这不是自连接的情况。
SELECT atable.c1 AS ac1, btable.c1 as bc1
FROM (
SELECT a.c1
FROM table_child a
WHERE a.c2='XXX') atable
LEFT OUTER JOIN (
SELECT b.c1
FROM table_child b
WHERE b.c3 ='YYYYY') btable
ON atable.c1 = btable.c1
我知道如何使用 DetachedCriteria
使用 org.hibernate.criterion.Subqueries
来执行 IN()
、NOT EXISTS 等操作()
等。但是 SubQueries
类似乎主要用于 WHERE
子句。
如何使用子查询来执行连接,如上面的 SQL 查询所示。我需要使用 Hibernate Criteria Query 来完成此操作。
谢谢。
I have a requirement to convert the below SQL query into a criteria query.
There is just one table and note that it is not a case for self join.
SELECT atable.c1 AS ac1, btable.c1 as bc1
FROM (
SELECT a.c1
FROM table_child a
WHERE a.c2='XXX') atable
LEFT OUTER JOIN (
SELECT b.c1
FROM table_child b
WHERE b.c3 ='YYYYY') btable
ON atable.c1 = btable.c1
I am aware of how to use DetachedCriteria
using org.hibernate.criterion.Subqueries
to do things like IN()
, NOT EXISTS()
, etc. But the SubQueries
class seems to be mainly for WHERE
clause.
How do I use a SubQuery to perform a join as shown in the above SQL query. I need to do this using Hibernate Criteria Query.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论