How would I code a query involving a union all in the *hbm.xml file?
For instance:
select error_cd, sub_code, message, component from error_messages where error_cd < 0 union all select errno, 0, errstr, user from syslog_msg where errno > 0
Hibernate does not support union in the query language (and probably won't, in the near future). However, in Hibernate 3.0, there is the <union-subclass> mapping, which is useful in some circumstances.
Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/193239415X/ref=jranch-20" target="_blank" rel="nofollow">Hibernate in Action</a>
For the overwhelming majority of cases, Hibernate2 provides all the O/R mapping options you will need. However, there are now a few new features that are powerful, if used judiciously.
single-class-to-multiple-table mappings using <join> table-per-concrete-class-mappings using <union-subclass> flexible discriminators using SQL formula mappings
The new <union-subclass> construct provides an explicit way to map classes to a table-per-concrete-class model and is implemented using SQL UNIONs.
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.