[jboss-user] [JBoss Seam] - Re: EntityHome.persist fails with @GeneratedValue

asookazian do-not-reply at jboss.com
Fri Dec 21 10:10:15 EST 2007

well I determined the root cause of the exception I was getting (org.hibernate.PersistentObjectException: detached entity passed to persist: com.cox.beans.entity.TblSecurityAuditNote).  It was that I had a loop that was trying to persist an already perstisted/inserted JPA entity into the DB and Hibernate notices this and throws the exception before you get a primary key violation SQLException from DB.

So in my case it was a programmer's error. The fix was to set the already persisted entity to null in the array so in the code it will not exec the em.persiste(note) again.

I think that the wording of the hibernate exception could be more clear.  I still don't understand exactly what it's trying to indicate literally (I now know it's saying you're trying to insert a record in the table which has an existing primary key value).

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114996#4114996

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114996

More information about the jboss-user mailing list