Hi,
I've problem executing this piece of code in Stateful
seam component:
// create new entity object Car myCar = new Car(); myCar.setType("van"); // save entity for a first time - entity is save correctly in database log.debug("Saving car: " + myCar); entityManager.persist(myCar); // update entity member parameter myCar.setType("truck"); log.debug("Changing car type to: " + myCar); // flush manager - maybe not needed ? log.debug("Flushing manager"); entityManager.flush(); // saving updated entity - this one is causing exception: "Another user changed the same data, please try again" log.debug("Saving changed car : " + myCar); entityManager.persist(myCar);
As result in log file I can find error mesage:
org.hibernate.event.def.AbstractFlushingEventListener: Could not synchronize database state with session
and in the bowser this message appears:
Another user changed the same data, please try again
My question is:
Entity is created in database but updated causes exception - how to perform this action ?