aspose file tools*
The moose likes Object Relational Mapping and the fly likes PersistentObjectException: detached entity passed to persist  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "PersistentObjectException: detached entity passed to persist  " Watch "PersistentObjectException: detached entity passed to persist  " New topic
Author

PersistentObjectException: detached entity passed to persist

jeff mutonho
Ranch Hand

Joined: Apr 30, 2003
Posts: 271
I'm trying to do a simple persisting of an object into a MySQL database , with the following code:

When I run this I'm getting a org.hibernate.PersistentObjectException: detached entity passed to persist .The full stacktrace is as follows:

srinivas bodduluri
Greenhorn

Joined: Feb 26, 2009
Posts: 3
The way you presented in the first code snippet for the lines is wrong.

you need to create UserBean object after beginning the transaction.

or what you can do is

instead of em.parsist just use merge. since user object in the above code treat it as detached object. you will have to reattach by using merge but not with parsist.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PersistentObjectException: detached entity passed to persist
 
Similar Threads
student record doesn't added
detached entity passed to persist
NonUnique Object Exception
Caused by: java.sql.SQLException: Statement parameter 2 not set.
Set an auto-incremented key