I'm assuming:
Quote:
(SELECT OBJ1.ID, OBJ1.DESCRIPTION
FROM OBJECT1 OBJ1)
UNION
(SELECT OBJ2.ID, OBJ2.DESCRIPTION
FROM OBJECT1 OBJ1)
is supposed to read:
Quote:
(SELECT OBJ1.ID, OBJ1.DESCRIPTION
FROM OBJECT1 OBJ1)
UNION
(SELECT OBJ2.ID, OBJ2.DESCRIPTION
FROM OBJECT1 OBJ2)
If that is the case, then you can get Hibernate to kind of do a union in Java land, if (and only if) OBJ1 and OBJ2 have a common superclass (that no other classes have).
If they currently don't have a common superclass, you can do someting as simple as making them both implement the same tag (ie. empty) interface.
All you need is to do the query on the base class and Hibernate will do two separate SQL queries and return you one collection containing all the results.
Let me know if you use this method because I've not used it in a production situation and I'd be interested in hearing about any issues with it (as I do plan to use this technique eventually).
P.S. If you're doing the query in HQL land, make sure you specify the fully qualified classname of the base-class in the query.