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 |