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

What is database deadlock ?

0 Answers  


What are the higher level apis under development on top of jdbc currently?

0 Answers  


What are the considerations for deciding on transaction boundaries?

0 Answers  


What type of driver you use in real-time projects?

3 Answers  


How does jdbc connect to database?

0 Answers  


How to store images in database?

2 Answers  


Define preparedstatement.

0 Answers  


How can I use the JDBC API to access a desktop database like Microsoft Access over the network?

0 Answers  


Is possible to open a connection to a database with exclusive mode with JDBC?

0 Answers  


How transactions are performed using JDBC ?

2 Answers  


How can you tune SQL statements?

2 Answers   Wipro,


Which jdbc driver is the fastest driver?

0 Answers  


Categories