-->
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: Deleting child-end of associations
PostPosted: Thu Dec 22, 2005 3:48 am 
Newbie

Joined: Fri Dec 16, 2005 12:31 am
Posts: 6
Hello -

I am using Hibernate 2.1.6 and have a one-to-many association as shown below:

ParentClass.java---------- Table: PARENT_CLASS

ParentClass {

Collection childClass;

/**
* @hibernate.set role="children" inverse="false"
* cascade="all-delete-orphan"
* @hibernate.collection-key column="parent_id"
* @hibernate.collection-one-to-many
* class="com.samples.ChildClass
*/
public Collection getChildClass () {
return this.childClass;
}
}


ChildClass.java---------- Table: CHILD_CLASS

ChildClass {

ParentClass parentClass;
int number;

/**
*
* @return
* @hibernate.many-to-one column="parent_id"
* class="com.samples.ParentClass"
*/
public ParentClass getParentClass () {
return this.parentClass;
}
}


I'd like to delete all the rows in the child table where the 'ChildClass.number' attribute is equal to 100.

I tried using a build clause that basically used a where childClass.number = 100 but end up getting the following exception:


HibernateObjectRetrievalFailureException :

"deleted object would be re-saved by cascade (remove deleted object from associations): 12345, of class: com.samples.ChildClass"


What does this mean?

What do I need to include in my XDoclet tag definition for the mapping so that I could execute a single delete?

Quick suggestions will be appreciated!

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 22, 2005 4:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
go to the user forum - thanks.

_________________
Max
Don't forget to rate


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.