-->
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: collection with two open sessions revisited
PostPosted: Tue Nov 15, 2011 5:34 pm 
Newbie

Joined: Wed Feb 23, 2011 9:25 pm
Posts: 12
I have some code that results in the exception: Illegal attempt to associate a collection with two open sessions

Searching via Google this seems to occur in a number of situations, but none of the other situations seems to fit what I am seeing. For example, I do not use @ManyToOne(cascade = CascadeType.ALL) anywhere.

I always use .getCurrentSession() to get a session, so I am not clear on how I could have two open sessions.

Does anyone have any other suggestions on why this might happen?


Top
 Profile  
 
 Post subject: Re: collection with two open sessions revisited
PostPosted: Tue Nov 15, 2011 6:21 pm 
Newbie

Joined: Wed Feb 23, 2011 9:25 pm
Posts: 12
So, the fix seems to be to use session.merge() instead of session.update() - but I still do not know why hibernate thinks I have more than one session open. I cannot seem to find anything in the API to detect if another session is already open.

Given there are so many different causes of this exception, it would be nice if the hibernate diagnostics were a little more specific as to what the cause might be.


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.