vendredi 8 janvier 2016

org.hibernate.PersistentObjectException: detached entity passed to persist:

org.hibernate.PersistentObjectException: detached entity passed to persist:



you get this exception when want to add an object with JPA. 
The first time  everything goes fine and Object is inserted in the database. 
The second time,  it fails and you have this exception.
To resolve this do:
em.merge(user);
instead of
em.persist(user);




Aucun commentaire:

Enregistrer un commentaire