I am having an problem and I searched the hibernate FAQ and tried many
ways; but was not successful.
I have an Object Product which has another object called Solution
Product{
private String name;
private SolutionSet solutionSet;
/**
* @return Returns the solutionSet.
* @hibernate.many-to-one name="solutionSet"
* class="com.transunion.bpma.cwr.model.SolutionSet"
* column="soln_set_id" not-null="true" lazy="false"
inverse="false"
*/
public SolutionSet getSolutionSet() {
return solutionSet;
}
}
At the Solution side,
SolutionSet{
Set products = new HashSet();
/**
* @return Returns the solutionSet.
*
* @hibernate.set table="PRDT" cascade="save-update" lazy="false"
inverse="true"
* @hibernate.collection-key column="SOLN_SET_ID"
* @hibernate.collection-one-to-many
class="com.transunion.bpma.cwr.model.Product"
*
*/
public Set getProducts() {
return this.products;
}
}
When I save product without changing the solutionSet, I got the error:
org.hibernate.NonUniqueObjectException: a different object with the same
identifier value was already associated with the session
If I pick a different solutionSet (from solutionSet dropdown), I don't
see the error. It works fine. In other words, when I tried to save
product, I am forced to change solutionSet. Otherwise, it won't work.
>From FAQ, someone suggests to use getHibernateTamplate().merge(product),
insteand of getHibernateTempalate().saveOrUpdate(product); It makes no
difference. I tried evict(product), it makes no difference, either.
Does anyone experience this problem? How do I resolve this? Any help
is appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]