Problem:When i delete a subclass object
(HhgDriver) Hibernate also deletes the the superclass object
(Load) from the tables in DB.Whereas i just want to delete the subclass object and not the super class object.Similarly when i try to insert subclass object
(HhgDriver) Hibernate also inserts the the superclass object
(Load) in the tables in DB.How can i overcome this problem?
The detials of my mapping file and code snippet is given below-
Hibernate version: 2.1.7
Mapping documents:
Code:
<hibernate-mapping package="bar.foo.valueobjects">
<class name="Load" table="LOAD">
<id
column="LOAD_ID"
name="id"
type="integer"
>
<generator class="assigned" />
</id>
.....
....
.....
<joined-subclass name="HhgDriver" table="HHGDRIVR">
<key column="LOAD_ID" />
<property
column="UPD_DT"
length="26"
name="updDt"
not-null="false"
type="timestamp"
/>
<property
column="UPD_USER_M"
length="255"
name="updUserM"
not-null="false"
type="string"
/>
<many-to-one
class="Van"
name="vanN"
not-null="true"
>
<column name="VAN_N" />
</many-to-one>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
s = getSession();
t = beginTransaction(s);
//obj is of type HhgDriver
delete(obj, s);
commitTransaction(t);
Name and version of the database you are using:DB2 8.1
----------------
Thanx in advance
Nikhil