-->
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.  [ 3 posts ] 
Author Message
 Post subject: can't delete joined-subclass objects from database
PostPosted: Tue Jun 08, 2004 10:28 am 
Newbie

Joined: Tue Jun 08, 2004 9:50 am
Posts: 4
Location: Greece
My first message here. Congratulations for this great project! :D

But also, I have a problem with it :p. I can't remove a kind of objects from the database.

I have the folowing mapping for a class (with its subclasses)

Code:
<class name="GarmentContainer" table="containers">
   <id name="container_ID" column="container_ID" type="long">
      <generator class="identity"/>
   </id>
   <set name="contents">
      <key column="container"/>
      <one-to-many class="GarmentQuantity"/>
   </set>
   
   <joined-subclass name="Store" table="store">
      <key column="container_ID"/>
      <property name="code" type="string"/>
   </joined-subclass>

   <joined-subclass name="Box" table="boxes">
      <key column="container_ID"/>
      <property name="code" type="string"/>
      <property name="location" type="string"/>
   </joined-subclass>

   <joined-subclass name="Sale" table="sales">
      <key column="container_ID"/>
      <many-to-one name="customer" class="Customer" not-null="true"/>
   </joined-subclass>
</class>


Everything works great, except that i can't delete any Box from the database.

The code that i use, to delete the object is the following:

Code:
Session session = sf.openSession();
Box box = this.getBox(request.getParameter("code"), session);
...
do some things (remove all objects from the contents(SET) of the box)
...
and finaly try to remove the box
...
session.delete(box);
session.connection().commit();
session.flush();
session.close();


(I have also tried to set box.setContents(null) before deleting the box)

But nothing hapends. I don't know what is wrong. From the log files I see the SQL statements that say "delete from containers where container_ID=?" and "delete from boxes where container_ID=?".

Please tell me if I can provide any other details.

Thanks

_________________
Homo bandwidthous


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 10:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
flush() before commit()


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 6:17 am 
Newbie

Joined: Tue Jun 08, 2004 9:50 am
Posts: 4
Location: Greece
Hmmm. So it was so simple :p.

Thanks! :) (and sorry for the stupid question)

_________________
Homo bandwidthous


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.