• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate

 
Terry Milan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gavin King
author
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gavin King
author
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I should say that you can use a UNION in a native SQL query, of course...
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New in Hibernate3


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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic