Can we use union in hibernate?
Does anybody have any idea about unions in hibe开发者_如何学Crnate?
I got this question in a interview. My guess is yes, but I'm not sure where and when.
The answer is no... see here https://www.hibernate.org/117.html#A21
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.
精彩评论