A web application using UserTransaction with Hibernate and JBoss EJB.
Users edit a detached entity(retrieved by Hibernate) directly through web. When applying changes, em.merge() is called, but a Hibernate exception raised. In this case, the detached entity is given back to user for correcting errors. But incorrect behavior occured. Either saying the detached entity is stale, or creating duplicate entity, or WrongClassException.
Is the detached entity re-usable after Hibernate exception occurs? Is there a way to make it re-usable? User does not want to lose his/her changes, and just want to correct errors.
If making a copy of the detached entity and giving the copy to user for editing, user can keep the change after hibernate exception. But deep copy is expensive. There are many types of entities, and implementation of deep copies is not trivial. I am looking for a way to keep detached entities usable even after Hibernate exception raised. Is there a way?
Any idea/help are appreciated.
Thanks in advance.
|