带有弹簧数据jpa的并表 [英] Union tables with spring data jpa
本文介绍了带有弹簧数据jpa的并表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个表,一个是Users
,另一个是UserGroup
具有ManyToMany
关系,如何将它们与spring-data-JPA合并为一个列表.
I have 2 tables one is Users
and the other is UserGroup
Having ManyToMany
relationship , how can I union them into a single List with spring-data-JPA .
**不想使用本机查询
** don't want to use native Queries
更新:
我想要的确切查询:
选择来自用户的电子邮件
SELECT email FROM user
UNION
从组中选择标题
推荐答案
所以我解决了在数据库本身中创建视图,然后将其映射到我的Java实体的问题,因为休眠似乎不支持联合"查询
So I solved my problem with creating a view in database itself and then map that to my java entity because it seems that hibernate doesn't support 'union' query
这篇关于带有弹簧数据jpa的并表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文