Union-subclass in Hibernate Mapping by R4R Team

In hibernate we found third option is to map only the concrete classes of an inheritance hierarchy to tables. We called to this table-per-concrete-class strategy. In this strategy Each table defines all persistent states of the class, including the inherited state. In Hibernate, it is not necessary to explicitly map such inheritance hierarchies. Then we can map each class with a separate <class> declaration. We use polymorphic associations (association to the superclass of hierarchy), for this we need to use the <union-subclass> mapping. 


For example:


<union-subclass 

name="ClassName"

table="tablename"

proxy="ProxyInterface"

lazy="true|false"

dynamic-update="true|false" dynamic-insert="true|false" schema="schema" catalog="catalog" extends="SuperclassName" abstract="true|false" persister="ClassName" subselect="SQL expression" entity-name="EntityName" node="element-name"> 

<property .... /> ..... </union-subclass>


Below is the description given:


Tag

Description

name

fully qualified class name of the subclass

table

the name of the subclass table

proxy (optional)

specifies a class or interface used for lazy initializing proxies

lazy (optional)

defaults to true.

setting lazy="false" disables the use of lazy fetching

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!