Home  >  Forum  >  Hibernate
Post New Query

org.hibernate.PersistentObjectException: detached entity passed to persist

joined on
March 22,2015
Asked on November 22,2015
I am inserting row in MySQL database using Spring and hibernate. I am getting the following error. Any clue?

Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: 
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:139)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:75)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:811)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:784)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:789)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1181)

joined on
November 09,2013
Replied on November 22,2015

Check in your code that if you have used 


and at the same time you are inserting id (any primary key value) by code too.
Do not insert id by code if using @GeneratedValue

Write Answer

Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us