Reputation: 1213
I am getting NonUniqueObjectException when i persist an object using JPA.
The object where i make persisent, have other objects and in some cases the objects have the same id.
Make a merge in object where is already saved in DB is a possibility but i only can make persist at one object (this object have all information)
I can put any annotation on my id to make a merge when this id is already saved in MySQL database?
Upvotes: 0
Views: 158
Reputation: 597106
Use entityManager.merge(..)
or leave the id
field empty. Otherwise hibernate will check if an entity exists in the database with the same id and will fail if it finds one.
Upvotes: 1