The best way to use UNION, INTERSECT, and EXCEPT with Hibernate

Introduction In this article, we are going to see how we can write UNION, INTERSECT, and EXCEPT queries with Hibernate. While you could have always used all these relational set operations using native SQL queries, starting with Hibernate 6, you can use UNION, INTERSECT, and EXCEPT in JPQL and Criteria entity queries. This is all possible because of the new Semantic Query Model that Hibernate has introduced in version 6.