-->
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: Thread safety and lazy loading
PostPosted: Fri Oct 20, 2006 12:09 pm 
Regular
Regular

Joined: Tue Nov 16, 2004 6:36 pm
Posts: 62
Location: Zürich
Using hibernate 3.1.

I know that Session instances are not thread safe. However would it be save to load objects in a single thread, and then access these objects in multiple threads, given the fact that accessing these objects will trigger lazy loading?

I.e. the question is if lazy loading itself is thread safe, if internally it uses a single session?


Top
 Profile  
 
 Post subject: Re: Thread safety and lazy loading
PostPosted: Fri Oct 20, 2006 3:06 pm 
Newbie

Joined: Sun Jun 20, 2004 1:15 am
Posts: 5
plm wrote:
I.e. the question is if lazy loading itself is thread safe, if internally it uses a single session?


No. Sessions are not thread safe and therefore they can't be accessed from multiple threads (without external synchronisation of the Session) regardless of whether that access is direct ("session.persist(myObject)") or indirect (eg. via lazy loading).

Cheers,
Peter


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.