Hello All, I'm working on a Seam/EJB3 app where I have a persisted object that I am editing. The object has a many-to-one set, to which the user can add newly created objects via the UI. If the user adds an object and chooses "ok" to persist their changes then all is well, the new object gets persisted just fine. The problem I am having is when the user chooses "Cancel". Rather than unpicking their changes, I wanted to simply call em.refresh(obj) to reset the object back to the previous state, however I get the following exception when I try this:
No row with the given identifier exists: [com.example.model.Address#0] | at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) | at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:269) | at org.jboss.ejb3.entity.ExtendedEntityManager.refresh(ExtendedEntityManager.java:154) | at org.jboss.seam.persistence.EntityManagerProxy.refresh(EntityManagerProxy.java:133) So, it looks like the EM has tried to refresh one of the newly created child objects rather simply restoring the object's many-to-one set. If I call obj.getAddresses().clear() prior to calling refresh() then it succeeds. I get my object with the previous state. My (simplistic?) expectation of refresh was that I could call it regardless of the state I manage to get the object into and it will revert it back to the state of the database. Should this be the case? Cheers, Chris. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045994#4045994 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045994 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user