-->
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: Save One-to-Many - Pb Delete reference but not delete record
PostPosted: Fri Nov 19, 2004 12:13 pm 
Hibernate version:
2.1.5

Name and version of the database you are using:
MaxDB

Hello,

I have a problem with I use SaveorUdapte of an entity with a one to many association to an other entity.

Entity A (Car) : Volvo, Red,...

Enitty B (Wheel)
- Wheel 1 : Sport
- Wheel 2 : Sport
- Wheel 3 : Sport
- Wheel 4 : Sport
- Wheel 5 : Sport

This records is in my database. I would like to modify the entity A and delete Wheel 5.

I use SaveOrdate in this new entity. But Hibernate delete only the reference to the Wheel 5 and not delete this records

<set name="wheel" lazy="false" inverse="false" cascade="all" sort="unsorted" >
<key column="id_car" >
</key>
<one-to-many class="com.wheel" />
</set>

Thks for your Help
Franck


Top
  
 
 Post subject:
PostPosted: Fri Nov 19, 2004 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why should it delete the other entity? You only dereferenced it from the collection, that doesn't mean it has to be deleted. It could be referenced by another entity. You have to explicitely delete() it after taking it out of the collection. (Read the documentation or HiA again and try to think about "entity" and "value type".)

You are probably looking for cascade="all-delete-orhpan", but you should only use this shortcut if you understand object lifecycle and sahred references completely.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.