I am using Roo 1.0.2.
If I call merge() on an entity twice (for instance pressing save button twice in gui) I get a
org.springframework.orm.jpa.JpaOptimisticLockingFa ilureException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction
The entity has not changed or been updated by another.
If I try to simulate it in a test:
I getCode:Person p = new Person(); p.setUniqueField("0000000000"); p.merge(); p.merge();
org.springframework.dao.DataIntegrityViolationExce ption: org.hibernate.exception.ConstraintViolationExcepti on: could not insert: [Person]; nested exception is javax.persistence.EntityExistsException: org.hibernate.exception.ConstraintViolationExcepti on: could not insert: [Person]
So I try another simulation
The I get the JpaOptimisticLockingFailureException but not until line 10.Code:1 Person p = new Person(); 2 p.setUniqueField("0"); 3 p.merge(); 4 p = p.findPerson(p.getId()); 5 p.merge(); 6 p.merge(); 7 p.merge(); 9 p.setCityName("ZZZ"); 10 p.merge();
Can anybody explain to me what is going on here and how to fix this?
Regards
Christian


Reply With Quote
