hi all,
I have this Exception:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [LoginData#]
when I try to save the object User.
Code:
Session = HibernateSessionFactoryMaster.getSessionFactory().openSession();
session.beginTransaction();
session.save(user);
session.getTransaction().commit();
session.close();
My mapping:
Code:
<hibernate-mapping>
<class name="User" table="User" lazy="false">
<id column="Id" name="Id">
<generator class="guid"/>
</id>
<property name="login"/>
<list cascade="all" lazy="true" name="loginD" table="LoginData">
<key column="userId"/>
<list-index column="idx"/>
<one-to-many class="LoginData"/>
</list>
</class>
<class name="LoginData" table="LoginData" lazy="false">
<id column="loginDataId" name="loginDataId" unsaved-value="0">
<generator class="guid"/>
</id>
<property name="login"/>
<property name="password"/>
<property name="roleId"/>
</class>
</hibernate-mapping>
if a save before the object LoginData and then the object User works fine.... but it is necessary with cascade"all" ?
any ideas?
thanks