Wednesday, March 2, 2011

detached entity passed to persist

well, if your entity has already an ID, and you invoke
entitymanager.persist(bla)

Hibernate will think you are trying to persist an already existing entity, and he will react giving this stern and cryptic error message.

Just set the ID to null and you will smile again.

When mapping an entity to another, NEVER map the ID!

No comments: