gkpstar
gkpstar

Reputation: 123

Can we use union in hibernate?

Does anybody have any idea about unions in hibernate?

I got this question in a interview. My guess is yes, but I'm not sure where and when.

Upvotes: 6

Views: 6077

Answers (2)

atrain
atrain

Reputation: 9255

Even though you can't do a true union, you can simulate one if the union is for two different queries for the same entity. In that case, you can use a Disjunction to OR two or more different DetachedCriteria queries, using the output of those queries as inputs to a Restrictions.in against some column in the main entity. This method gets you the equivalent of a union.

Upvotes: 3

Chris Conway
Chris Conway

Reputation: 16529

The answer is no... see here https://www.hibernate.org/117.html#A21

Upvotes: 3

Related Questions