I am getting a weird problem in hibernate. I am using hibernate and spring in my project.
Problem is I am having a parent child relation, and when I try to update the parent I am getting the exception
Caused by: org.hibernate.HibernateException: Don't change the reference to a collection with cascade="all-delete-orphan"
Following are the mappings :
Parent :
<set name="kittens" fetch="join" lazy="false"
inverse="true" cascade="all-delete-orphan">
<key>
<column name="ID" precision="22" scale="0"
not-null="true" />
</key>
<one-to-many
class="kitten" />
</set>
Child :
<composite-id name="id" class="kittenId">
<key-property name="kittenId" type="java.lang.Long">
<column name="Kitten_ID" precision="22" scale="0" />
</key-property>
<key-many-to-one name="cat" class="cat">
<column name="ID" precision="22" scale="0" />
</key-many-to-one>
</composite-id>
I found in a forum and tried changing like
public void setKittens(Set kittens) {
this.kittens.clear();
this.kittens.addAll(kittens);
}
But now I am facing
org.hibernate.PropertyAccessException: Exception occurred inside setter of Kittens
Any help will be appreciated pls.