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



What is <discriminator > in Hibernate? How exactly inheritance of Object to Tables can be do..

Answer / 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

More JDBC Interview Questions

Why is odbc needed?

0 Answers  


What are the different classes through which JDBC represents statements?

0 Answers  


what is CallableStatement and what is its usage?

1 Answers  


How do we call a stored procedure from jdbc?

0 Answers  


What is correlated subquery?

0 Answers   emc2, JK Technosoft,






What is a JDBC 2.0 DataSource?

0 Answers  


What is an outer join?

3 Answers   Infogain,


What is JDBC ResultSet?

0 Answers  


What is JDBC Driver interface?

0 Answers  


Why should we close database connections in java?

0 Answers  


Which type of driver provides jdbc access via one or more odbc drivers?

0 Answers  


What is de-normalization?

1 Answers  


Categories