Hi,
I create a small test to check the merge functionality.
I basically:
1) retreive in one session (via JpaTemplate) an object.
2) Modify the object
3) from another session (still via JpaTemplate) merge the object.
When I check the database the object is not changed?
Here is a part of the code:
Code:
public void testUpdateColorStone() {
System.out.println("sssss START ssss");
TestObject testObject = (TestObject) testDAO.findByReference("Test");
System.out.println(testObject .getComments());
testObject .setComments("last comments");
System.out.println(testObject .getComments());
testDAO.merge(testObject );
}
I don't see in the log file any update statement!
My DAO use the entityManager to create a session.
[main] DEBUG org.springframework.orm.jpa.JpaTemplate - Creating new EntityManager for JpaTemplate execution
[main] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 4743565661175808
When I use the merge in the same session/transaction as the finder, it works but not with different session. Isn't it the goal of the merge to reattach an object and save it?
Any Idea?
Thanks
Dominique