struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Allen <...@mojavelinux.com>
Subject Re: ORMs proxies and lazy initialisations issues in the view
Date Thu, 12 Jun 2003 14:23:44 GMT
> For example, in the Hibernate FAQ, I've found this entry :
> "
> In an MVC application, how can we ensure that all proxies and lazy
> collections will be initialized when the view tries to access them?
> 1- One possible approach is to leave the session open (and transaction
> uncommitted) when forwarding to the view. The session/transaction would be
> closed/committed after the view is rendered in, for example, a servlet
> filter (another example would by to use the ModelLifetime.discard() callback
> in Maverick). One difficulty with this approach is making sure the
> session/transaction is closed/rolled back if an exception occurs rendering
> the view.
> 
> 2- Another approach is to simply force initialization of all needed objects
> using Hibernate.initialize(). This is often more straightforward than it
> sounds.
> 
> "

I believe there is a 3rd option not mentioned on the Hibernate FAQ
page that uses a Filter for this exact purpose.  I have found that
it is much simpler to use filters around struts then to try to
modify struts source code.  Here is the link:

http://hibernate.bluemars.net/43.html

Has anyone successfully gotten lazy initialization to work in struts without
having to resort to Hibernate.initialize(), because again, how would
we know what the view is going to use the data for.  The view might
do something like?

user.company.industries

When all we gave them was user...it would be very hard to initialize
all those paths.

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <dan@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
"I am the GOD.....the GOD...of house!" 
 -- Leeloo
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message