-->
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.  [ 6 posts ] 
Author Message
 Post subject: Illegal attempt to associate a collection
PostPosted: Fri Jun 11, 2004 2:12 am 
Newbie

Joined: Sat Nov 01, 2003 12:35 pm
Posts: 11
Hi,
I meet an error "Illegal attempt to associate a collection with two open sessions". By searching related mails in this mail list, I find similar problem. However, i still cannot figure out my problem. I track the source code of hibernate, i find the error happens when handling proudcts collection, which has o2r mapping as follows:

<set name="products" table="PI_TMP_CP_BR_PRODUCT" cascade="none">
<key column="BR_OID"/>
<many-to-many column="PRODUCT_ID" class="com.tsmc.pdmcp.basicrecord.CPProduct"/>
</set>
. Could someone help?

Regards,
Rice



2004-06-11 14:03:20,020 [69831] INFO [ExecuteThread: '14' for queue: 'default']
- initialize persistence session
net.sf.hibernate.HibernateException: Illegal attempt to associate a collection w
ith two open sessions
at net.sf.hibernate.collection.PersistentCollection.setCurrentSession(Pe
rsistentCollection.java:262)
at net.sf.hibernate.impl.OnUpdateVisitor.processCollection(OnUpdateVisit
or.java:38)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.ja
va:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.j
ava:36)
at net.sf.hibernate.impl.AbstractVisitor.process(AbstractVisitor.java:93
)
at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:14
26)
at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1440)
at net.sf.hibernate.impl.SessionImpl.update(SessionImpl.java:1326)
at com.tsmc.pdmcp.persistence.PersistenceManager.change(PersistenceManag
er.java:169)
at com.tsmc.pdmcp.basicrecord.CPBasicRecordManager.changeCPBasicRecord(C
PBasicRecordManager.java:67)
at com.tsmc.pdmcp.usecase.basicrecord.CPBasicRecordUseCase.saveCPBasicRe
cord(CPBasicRecordUseCase.java:257)
at com.tsmc.pdmcp.usecase.basicrecord.CPBasicRecordUseCase.doOperation(C
PBasicRecordUseCase.java:78)
at com.tsmc.pdmcp.ejb.PDMCPSessionBean.doUseCase(PDMCPSessionBean.java:5
0)
at com.tsmc.pdmcp.ejb.PDMCPSessionBean_70supp_EOImpl.doUseCase(PDMCPSess
ionBean_70supp_EOImpl.java:37)
at com.tsmc.pdmcp.ejb.PDMCPSessionBean_70supp_EOImpl_WLSkel.invoke(Unkno
wn Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:265)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
2004-06-11 14:03:20,170 [69981] ERROR [ExecuteThread: '14' for queue: 'default']
- com.tsmc.pdmcp.persistence.PersistenceException: net.sf.hibernate.HibernateEx
ception: Illegal attempt to associate a collection with two open sessions
2004-06-11 14:03:20,180 [69991] INFO [ExecuteThread: '14' for queue: 'default']
- closing persistence session


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 11, 2004 3:58 am 
Newbie

Joined: Sat Nov 01, 2003 12:35 pm
Posts: 11
Hi,

I find the error of this problem. Thanks.

Regards,
Rice


Top
 Profile  
 
 Post subject: Cause?
PostPosted: Thu Jun 24, 2004 2:44 am 
Newbie

Joined: Mon Feb 23, 2004 8:30 am
Posts: 13
Location: Istanbul, Turkey
Hi,

What was the cause of the problem?

THanks...

_________________
Mert Nuhoglu
http://jroller.com/page/mnuhoglu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 12:30 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The collection was loaded in one session
then a second sesison wa opened (wo closing the previous)
and the collection was reattached to the second session

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 8:43 am 
Newbie

Joined: Wed Feb 08, 2006 8:20 am
Posts: 2
emmanuel, would just closing the first session be enough for the collection to be correctly reattached to the second session?.

I had a simmilar problem to the one desribed above, where I was retrieving a Collection through session1, disconnecting it, and then saving the collection through a new session2.
So, in order to deassociate the collection from the first session, I tried closing session1, and then saving through session2, but the same exception would show up.

Thanks in advance,

_________________
Pepe


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 9:05 am 
Newbie

Joined: Wed Feb 08, 2006 8:20 am
Posts: 2
I've solved my problem, which had nothing to do with Hibernate itself.
My IDE was simply not deploying cleanly, so what was being run is not what I was expecting.

So, the framework correctly reattaches the collection to a second session provided that at the moment of reattachment:
- the first session used to retrieve it, is closed.
- the Java identity of the collection is the same that Hibernate returned at the moment of retrieval.

_________________
Pepe


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