Mapping documents:
<hibernate-mapping> <class name="model.Unit" table="UNIT"> <id name="id" type="string" unsaved-value="null"> <column name="UNITID"/> <generator class="uuid.hex"/> </id> <property name="name" column="NAME" not-null="true"/> <property name="description" column="DESCRIPTION"/> <many-to-one name="parentUnit" column="PARENT_UNITID" class="model.Unit"/> <set name="units" table="UNIT" cascade="all" lazy="true" inverse="true"> <key column="PARENT_UNITID"/> <one-to-many class="model.Unit"/> </set> </class> </hibernate-mapping>
Unit.java:
public class Unit { private String id = null; private String name = null; private String description = null; private Unit parentUnit = null; private Set units = new HashSet(); // getter and setter methods }
When I want to update an unit, I got the exceptions below, the save method works well.
Full stack trace of any exception that occurs:
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 2c9081b90238110701023811a13a0003, of class: model.Unit at net.sf.hibernate.impl.SessionImpl.checkUniqueness(SessionImpl.java:1686) at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1452) at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1479) at net.sf.hibernate.impl.SessionImpl.update(SessionImpl.java:1364) ......
Thank you in advance!
|