Hi All,
This question is regardig 'Table per class hierarchy' mapping.
I have a class A.
I have a class B extends A.
I have only one table (say T1) in the database for both A and B.
class A {
private String a1;
private String a2;
private String a3;
// Setters and Getters here
}
class B extends A {
private String b1;
// Setters and Getters here
}
Table T1 has columns as follows:
A1_COL VARCHAR2(10) PK
A2_COL VARCHAR2(10)
A3_COL VARCHAR2(10)
B1_COL VARCHAR2(10)
Suppose T1 has a row like this:
100 200 300 null
<hibernate-mapping>
<class name="foo.A" discriminator-value="0" table="T1">
<id name="id" column="A1_COL">
<generator class="sequence">
<param name="sequence">SEQ_A1</param>
</generator>
</id>
<discriminator column="DISCRIM_A1" />
............
............
<subclass name="foo.B" discriminator-value="17">
<property name="b1" column="B1_COL" type="string"/>
</subclass>
</class>
</hibernate-mapping>
Using Hibernate program I need to do the following task:
1) Retrieve the row based on primary key (100).
2) Set "B1_COL" value to 500 instead of null.
3) Update the database with new values.
I mean the above program should result in the following row in Database.
100 200 300 500
Appreciate your quick help.
This might be simple question, but i am new to Hibernate, so kindly help me.
Thanks n Have a nice day,
|