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: multiple thread/sessions and lazy load
PostPosted: Fri Aug 27, 2004 12:20 pm 
Newbie

Joined: Thu Mar 25, 2004 4:09 pm
Posts: 6
Hibernate version: 2.1.4

Mapping documents:

<set name="infosetDocuments" table="infoset_document_assn" inverse="true" cascade="all-delete-orphan" order-by="id" lazy="true">
<cache usage="read-write"/>
<key column="infoset_id" />
<one-to-many class="com.potomacfusion.vid.dao.InfosetDocumentAssn" />
</set>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions

Name and version of the database you are using: mysql 4

Debug level Hibernate log excerpt:

To avoid problems that might arise due to the fact that the Session object isn't threadsafe I'm working with the session-per-thread architecture as described in 'Hibernate in Action' with second level caching enabled (ehcache). As an example one of my 'application transactions' is contained in a web service that starts multiple threads that each need to modify the same persistent object(s). One of my objects contains a collection that I want to lazy load however when I persist one of these objects I get the exception described above. Why are collections associated with a specific Session ands not the current Session? What architecture can I use insure that all of the threads are modifing that same copies of the object (avoiding overwrites)?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 28, 2004 11:25 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Quote:
As an example one of my 'application transactions' is contained in a web service that starts multiple threads that each need to modify the same persistent object(s)

Probably you are doing something wrong (it can not work), you need to find a way without multiple threads, It must be always possible to find this way.


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.