Search code examples
javaspringhibernatejpaspring-data-jpa

Union tables with 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

UPDATE:

The exact query that I need:

SELECT email FROM user

UNION

SELECT title FROM group


Solution

  • 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