The UNION clause specifies a combination of the output of two subqueries. The two queries must return the same number of elements and compatible types.
query_expression := query_term [UNION [ALL] query_term]* query_term := {select_clause_dynamic from_clause [where_clause] [group_by_clause] [having_clause] } | (query_expression) }
You cannot use dependent value objects with UNION.
UNION ALL combines all results together in a single collection.
UNION combines results but eliminates duplicates.
If ORDER BY is used together with UNION, the ORDER BY must refer to selection expression using integer numbers.
select e from EmpBean e union all select m from DeptBean d, in(d.mgr) m
select e from EmpBean e union all select d from DeptBean d