Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PersistentObjectException: detached entity passed to persist

 
jeff mutonho
Ranch Hand
Posts: 271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic