如何使用JPA Hibernate在同一张桌子上进行子查询?

发布于 2025-02-13 00:10:30 字数 118 浏览 0 评论 0原文

帮助我将下面提到的查询转换为Hibernate JPA。 查询查询= EntityManager.Createquery(“从表1中选择a,b,c,d,其中d in(从table1中选择d,其中a = 1和b = 2”);

Help me to convert the below mentioned query to Hibernate JPA.
Query query= entityManager.createQuery("Select a,b,c,d from table1 where d IN (Select d from table1 where a=1 and b=2");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半寸时光 2025-02-20 00:10:30

只是给别名应该起作用

entityManager.createQuery("Select a,b,c,d from table1 t
 where t.d IN (Select r.d from table1 r where r.a=1 and r.b=2");

Just giving an alias should work

entityManager.createQuery("Select a,b,c,d from table1 t
 where t.d IN (Select r.d from table1 r where r.a=1 and r.b=2");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文