-->
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: long session and lazyness
PostPosted: Wed Mar 24, 2004 11:11 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
I was wondering if there is common solution to my problem with lazy objects.

When there is a long process that may run over hours we have many objects that are stored in caches. These objects can have nested objects which are all lazily fetched. This means that I either have to hold a session open indefinately so these lazy properties can be accessed or I need to open a new session and lock these objects back in before accessing nested objects.

Or something else.

Is there any common method for dealing with lazy relationships on objects that are stored for a significant period of time?

My main concerns are:

1) If I have one session and keep it open for a long long time it may start to consume a lot of memory and eventually cause heap errors. I don't know how hibernate caches objects but presumably something must be stored internally to detect changes and for pure caching purposes.

I don't think I can use clear() as this will evict objects I may eventually need to access lazy properties of.

2) Objects may be passed out to other threads that hold onto the object and at some point want to access nested objects. If the session of the thread that created the object is closed it won't work.

3) The re-lock all objects on use is quite cumbersome to do as you have to know whether an object has a session and re-lock it if necessary. I don't really want to have to do this.

I'm not sure I've described this sufficiently but any ideas or suggestions would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 11:12 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Your first solution should be to fetch all the data/objects required for a use case, just like with plain SQL/JDBC. You already know the other options.

_________________
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.