Subclass in Hibernate by R4R Team

Subclass in Hibernate: We use the table-per-class hierarchy mapping strategy, the <subclass> declaration is used. In hibernate Polymorphic persistence requires the declaration of each subclass of the root persistent class. 


For this we take a example which is given below:


<subclass 

name="ClassName"

discriminator-value="discriminator_value"

proxy="ProxyInterface"

lazy="true|false"

dynamic-update="true|false" dynamic-insert="true|false" entity-name="EntityName" node="element-name" extends="SuperclassName"> <property .... /> ..... </subclass>


Tag Description is given below:


Tag

Description

name

fully qualified class name of the subclass

discriminator-value(optional)

defaults to the class name.

value that distinguishes individual subclasses

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


Each subclass declares its own persistent properties and subclasses. <version> and <id> properties are assumed to be inherited from the root class. Each subclass in a hierarchy must define a unique discriminator-value. If this is not specified, the fully qualified Java class name is used.
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!