|
I have my domain class defined like this
public class MyDomainClass { .................................................
private Set myCollection;
MyDomainClass(){ this.myCollection = new HashSet(); }
........
public void setMyCollection(Set myCollection){
if(myCollection != null){ this.myCollection.clear(); this.myCollection.addAll(myCollection); } } ..................................... }
In other words , i have implemented the set method so that the the myCollection set is managed correctly and we dont run into the dereferencing problem. I have "myCollection" attribute mapped in hibernate with the cascase option of "all-delete-orphan". Now, I am still seeing the following exception :
"org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:" . But if i remove the "myCollection" initialization in the constructor, i no longer see the problem.
Should i NOT be initializing "myCollection" variable in the constructor?
RK
|