[jboss-user] [EJB/JBoss] - Re: EntityManager merge and the seam-registration example.

justinwalsh do-not-reply at jboss.com
Fri Jul 21 01:29:09 EDT 2006


Persist is used to insert a new instance of an object to the database.  
The underlying persistence engine (most probably hibernate) needs to know if your object is is a new object, or if is a detached instance (an instance already present in the database but not associated with the session).  The usual mechanism for doing this is by inspecting the @Id field for a null/non-null value.  (There are other mechanisms which you can employ using hibernate - but I'm not 100% sure if these are std J2EE 5 ways)

[For more information on this check out the hibernate forums/docs http://forum.hibernate.com]

So - if you try and persist (insert) an object that already has an identifer - you are going to get the exception you mentioned.

Entity beans by default are bound to the conversational context.  Have you explicitly bound the user to the session?  Show us the code that is creating the user and the user object.


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

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



More information about the jboss-user mailing list