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 difference between statement and preparedstatement in jdbc?

663


What is execute in java?

687


What does it mean to "materialize" data?

730


How can I write to the log used by DriverManager and JDBC drivers?

743


Define preparedstatement.

723


Does the database server have to be running Java or have Java support in order for my remote JDBC client app to access the database?

716


What is the significance of DataBaseMetaData.tableIndexStatistics? How to obtain and use it?

725


What is the use of jdbc?

759


What is JDBC Transaction Management and why do we need it?

736


Explain how to make updates to the updatable resultsets.

696


What is a jdbc driver and how many jdbc drivers are available?

771


Discuss the procedure of retrieving warnings?

733


What are the advantages of collection pools?

721


What is ojvm used for?

742


password, is stored in as plain text. What can I do to protect my passwords?

693