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!
|
|