What is <discriminator > in Hibernate? How exactly
inheritance of Object to Tables can be done? What is the
benefits of discriminator?
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 |
What is the use of getGeneratedKeys() method in Statement?
Which constraint cannot be specified as an explicit constraint and should be specified with the column only ?
Can we make a database connection from HTML ?
6 Answers Aptech, BOB Technologies, Cap Gemini, Wipro,
What is the use of JDBC DriverManager class?
java based application for hospital management
What is meant by dao?
Does sql allow null values ? Can we use it within where clause ?
How a driver can be loaded?
What is the difference between jdbc and odbc?
What class.forname will do while loading drivers of jdbc?
How to store images in database?
What is new in JDBC 2.0?