-->
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: lazy, web, pattern
PostPosted: Fri Dec 17, 2004 6:59 am 
Newbie

Joined: Thu Sep 18, 2003 3:34 am
Posts: 9
hi,

i just realized i'm very often facing repeating problem, maybe someone has suggestions on any pattern to solve it...

suppose there is part of web application where user browses data of some object (and related objects). the view is spawned on several pages (kind of workflow). the object being browsed is loaded on start of the browsing and is being kept in http session for later usage.

the object is related with some other objects and the relation is lazy-loaded.

the problem is that, the first access to the relation is not on first page of the workflow, so it doesn't get initialized (when using thread local session pattern). then the session is closed and relation cannot be loaded.

the only solution that comes to me is to force initialization of the relation after loading the object... but it's inconvenient and ugly - makes my view layer dependent on specific behaviour of data access layer.
session disconnection/reconnection could be solution here, but's inconvenient , too, and has it's drawbacks.

are there any other solutions of the problem?

the perfect one would be to force hibernate to always use current session to load lazy-initialized objects instead of throwing lazyinitializationfailedexception. i guess it's not that simple...

wojtek


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2004 7:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
just use long session per transaction application (see wiki)

DANGER: that doesn't mean long session per User HTTP session, that can be very dangerous.[/img]

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2004 10:49 am 
Newbie

Joined: Thu Sep 18, 2003 3:34 am
Posts: 9
i've already though of this solution, however - there is one practical problem regerding web apps - how to intercept end of application transaction (in order to close session).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2004 11:04 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
in hibernateUtils + hibernate filter
just take caveatemptor classes and modify it.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.