These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Delete of subclass delets the superclass also
PostPosted: Wed Dec 01, 2004 10:29 am 
Newbie

Joined: Wed Dec 01, 2004 8:52 am
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 01, 2004 4:15 pm 
Regular
Regular

Joined: Wed Nov 05, 2003 10:57 pm
Posts: 96
Use association instead of inheritance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.