What is <discriminator > in Hibernate? How exactly
inheritance of Object to Tables can be done? What is the
benefits of discriminator?

Answer Posted / haneef

Hi,
<discriminator> is useful, when you want to write a single
mapping file for the multiple pojo s which are under
inheritance.

Ex : Person<---Employee<----PermanentEmployee

<hibernate-mapping>
<class name="app.Person" table="ONE_PERSONS"
discriminator-value="p">
<id name="perId" column="PID">
<generator class="increment" />
</id>
<discriminator column="P_TYPE" />
<property name="perName" column="PNAME" />
<subclass name="app.Employee" discriminator-value="e">
<property name="empId" column="ENO" />
</subclass>
<subclass name="app.PermanentEmployee"
discriminator-value="pe">
<property name="allow" column="ALLOW" />
</subclass>
</class>
</hibernate-mapping>

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a jdbctemplate?

518


What are the different types of statements in jdbc?

484


Explain the difference between inner and outer join ?

512


What is use of connection pooling?

518


Does jdbc use ssl?

494






What is createstatement method in java?

508


What is the JDBC?

554


Why do you use a data source object for a connection?

537


Give an example for getXXX method?

553


What does executequery return in java?

503


What are different parts of a url?

499


How can you retrieve data from the resultset using jdbc?

547


What is an SQL Locator?

584


Define preparedstatement.

533


What is metadata in java programming?

490