-->
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.  [ 4 posts ] 
Author Message
 Post subject: transparent lazy loading
PostPosted: Sun Nov 16, 2003 3:07 pm 
Beginner
Beginner

Joined: Fri Oct 10, 2003 10:12 am
Posts: 39
hello,

appologies but i'm going to have to bring this up again in the hope that someone will have a solution or workaround.

I am making a client admin app and need to display a gui tree of the data graph. i would like to enable transparent lazy loading of the data so that the presentation tier is unaware of hibernate. the data graph is potentially huge - has the potential of being the entire database, so lazy-loading is a must.

The problem is that in order for the collections to load they must have an open session associated with them. One option, which i am not keen on, is to share one session with all objects in the graph and leave it open for the entire life of the application.

So, discarding that i need some way for the collection to be assigned to a new session, loaded and then the session closed, all transparent to the ui & user.

i have thought about implementing my own collection loading queries in a dao, but then i would miss out on the save\update features supplied with the hibernate collection framework.

i have also thought about having a separate businessobject hierarchy for hibernate and passing initialized collections over to the application Bo hierarchy on first demand, but this would double the number of objects in the system both in staticlly and at runtime, and it would would initialize the collection on method call instead of on a read.

does anyone have any ideas that i haven't thought of, or any comments on these?

thanks, cam


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 16, 2003 3:24 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Leave the Session open until your View is rendered. See the "Open Session in View" pattern on the Wiki.

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 8:41 am 
Beginner
Beginner

Joined: Fri Oct 10, 2003 10:12 am
Posts: 39
the problem with this pattern is that there is hibernate session & transaction code outside of the dao and in the presentation tier. since i am building a desktop app, this means that i would have to have this code embedded in actions\commands.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 6:47 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
I have similar problem. But I will also use the same ( almost ) dao
inside web tier.

On a web tier you have clear request scope - no problem with session management.

On SWING side I use the same DAO, and adapter class, where
my app can signal change on particular persistend object, and
have listeners to be notified.
( on first attempt I used reflection proxy to automatically determine when to fire events, but I decided that explicit calls are beter manageable )


My data models ( currently list models, but also trees in near future )
hold only IDs of persistent objects, to save memory.

When list/tree need to render entity, I just use session.load( clazz , id ) - my DAO layer always has a session active, though it may flush/close transparently - to be sure that object is from current session and proxies/collections can be resolved safely.

As for performance - loading some 25K entities into list models
takes some time, but interative performance is OK....

If this is not enough caching of strings / images is also possible...


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