-->
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: Hibernate session from ThreadLocal problem
PostPosted: Sun Jun 06, 2004 11:53 am 
Beginner
Beginner

Joined: Thu Oct 09, 2003 11:41 am
Posts: 39
Location: Paris, France
Hello,

I've set up HibernateSession for a web application via ThreadLocal as suggested here

http://www.hibernate.org/42.html

It's working but there is an exception that's popping up.

Code:
Caused by: net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
   at net.sf.hibernate.collection.PersistentCollection.setCurrentSession(PersistentCollection.java:257)
   at net.sf.hibernate.impl.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:38)
   at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
   at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
   at net.sf.hibernate.impl.AbstractVisitor.process(AbstractVisitor.java:93)
   at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1448)
   at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1462)
   at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1385)
   at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
   at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
   at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
   at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
   at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1467)
   at net.sf.hibernate.impl.SessionImpl.update(SessionImpl.java:1347)
   at LayoutManager.commitLayoutToDB(LayoutManager.java:498)
   ... 44 more


Shall I close the session after each request or chunk of operations? Or disconnect it?

Thanks & Regards


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 11:56 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Sure, http://www.hibernate.org/Documentation/ ... ctionScope

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.