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 are types of resultset?

563


What is jdbc and why is it required?

467


What is jdbc and odbc?

512


How can we store and retrieve images from the database?

517


How many types of JDBC Drivers are present and what are they?

509






How can I retrieve a String or other object type without creating a new object each time?

583


Which database is used with java?

501


What is a jdbc connection?

474


What is difference between odbc and jdbc?

512


What is a lock in jdbc?

545


What is thin driver in jdbc?

512


How to know howmuch data is truncated?

1921


Give an example for execution of sql statement.

532


What are the advantages of using preparedstatement in java?

549


What is metadata in java programming?

493