The #unionQuery is interesting idea. I do think it will be possible to implement UNION as a HQL language feature though given the design of SQM and the SQL AST (internal “query syntax trees”). Possibly even using the support for CTE statements - see org.hibernate.query.sqm.tree.cte.SqmCteStatement}}and {{org.hibernate.sql.ast.tree.cte.CteStatement |