-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Detached entity passed to persist?
PostPosted: Tue Jul 04, 2006 10:55 am 
Newbie

Joined: Mon Nov 28, 2005 12:43 am
Posts: 9
Thanks in advance for any help.

I have a user Entity that is stored in a WebApp Session object upon login. This object is created via a request to a Query object obtained through a Manager which is immediately closed.

I want to associate this user Entity to other types of Entities when they are created via a differenct Manager. When I create these other type of Entities (which have a many-to-one relationship with the user Entity) I get an exception:Detached entity passed to persist.

I try to re-attach the Entity by executing Manager.merge(user); but I still get the error.


Thanks in advance for any tips/advice.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 1:50 pm 
Newbie

Joined: Mon Nov 28, 2005 12:43 am
Posts: 9
Well - I figured out what I was doing wrong.

In addtion to using manager.merge(user) I also had t use manager.merge(otherEntity) instead of manager.persist(otherEntitiy).

In otherwords, I misunderstood that I only had to merge the detached object and then I could persist the newly created object which reference the (now attached) object. Instead, I merged both.

Its working now, but any additional opinions/feedback welcomed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.