Hi,
For few days I try to well understand Play & JPA stuff. Not easy for
me ... So I come to you for some help on the pretty simple example:
@Entity
public class ClassA extends GenericModel {
@Id
public int id;
public String code;
}
public class JPAGenericModelTest01 extends UnitTest {
@Test
public void Test01() {
ClassA a = new ClassA();
a.id = 1;
a.code = "abc";
a.save();
JPA.em().flush();
JPA.em().clear();
ClassA b = new ClassA();
b.id = 1 ;
b.code = "def";
b.merge();
b.save();
JPA.em().clear();
ClassA c = ClassA.findById(1);
assertEquals("def", c.code);
}
}
The run of Test01() throw a NonUniqueObjectException at b.save() :
javax.persistence.PersistenceException:
org.hibernate.NonUniqueObjectException: a different object with the
same identifier value was already associated with the session.
If I only do the merge(), don't call b.save() after the merge(), the
change on ClassA.code property is not updated: assertEquals("def",
c.code) failed.
Please, could you give me some light on that case ?
Thanks
Cyrille.