-->
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.  [ 4 posts ] 
Author Message
 Post subject: Illegal attempt to associate ...
PostPosted: Wed Aug 27, 2003 5:39 am 
Newbie

Joined: Wed Aug 27, 2003 5:35 am
Posts: 5
Hi,

I think it is a basic problem, but I don't know how to solve it.

I have a class generate by hbm2java, that contains lazy instanciation.

When I try to delete it , hibernate throw an exception with this msg :
Illegal attempt to associate a collection with two open sessions

It is sure that it is due to the lazy because I open a new session to delete this object, but How can I delete this class .?

thx a lot
nosnos


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 5:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It helps to read the exception message. You can not have a collection associated with two open sessions. This exception probably occurred because you forgot to close the provious session. It has nothing to do with laziness.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 12:50 pm 
Newbie

Joined: Mon Jun 11, 2007 12:32 pm
Posts: 1
Hello,

I got the same problem today and found a solution.
In my situation the cascade attribute in all many-to-one relations caused the exception.

_________________
No pain, no gain.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 16, 2007 11:50 am 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
Same here. In my case I was attempting Session.saveOrUpdate() on a detached object. I opened one session+transaction per object and made one call to saveOrUpdate(). I was still getting "Illegal attempt to associate a collection with two open sessions." The only solution that's worked (so far) is setting cascade="none" on various many-to-one mappings. I also want to try replacing saveOrUpdate() with merge(), but I haven't been able to test that yet,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.