-->
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 loading VS persistent storage decoupling
PostPosted: Fri May 22, 2009 12:07 pm 
Newbie

Joined: Sat May 09, 2009 3:19 pm
Posts: 9
How does the philosophy of trying to decouple the persistent storage implementation from the rest of your application fit in with lazy loading? (You cannot determine when you want something initialized without some business logic.)

Apparently, since no one can answer this, they are mutually exclusive and so lazy loading does not follow the best practices as specified through standard design patterns.

Why are we having this anti-best practices approach sold to us?


Top
 Profile  
 
 Post subject: Re: Lazy loading VS persistent storage decoupling
PostPosted: Sat May 23, 2009 8:15 pm 
Newbie

Joined: Tue Aug 07, 2007 12:46 pm
Posts: 4
The idea is to have all business code within the scope of a transaction / Hibernate Session, so that in effect lazy exceptions would not be an issue. However this requires significant thought when designing an architecture and is not always possible. In any architecture where detached objects are present you'll eventually have to solve lazy exception issues, either by eagerly loading whatever is necessary before detaching the objects, or otherwise by having some sort of rule which you obey throughout the app so you know whether you have the data available or not. It's not easy. But no one said enterprise architecture is easy :-)


Top
 Profile  
 
 Post subject: Re: Lazy loading VS persistent storage decoupling
PostPosted: Tue May 26, 2009 9:58 am 
Newbie

Joined: Sat May 09, 2009 3:19 pm
Posts: 9
mads1980 wrote:
The idea is to have all business code within the scope of a transaction / Hibernate Session, so that in effect lazy exceptions would not be an issue. However this requires significant thought when designing an architecture and is not always possible. In any architecture where detached objects are present you'll eventually have to solve lazy exception issues, either by eagerly loading whatever is necessary before detaching the objects, or otherwise by having some sort of rule which you obey throughout the app so you know whether you have the data available or not. It's not easy. But no one said enterprise architecture is easy :-)


But then you are not decoupling persistant storage, which is supposed to be an important design pattern.
Your persistance code is embedded in your business logic, or vice versa.
So by using lazy loading, you are breaking one of the main tennants of design patterns.


Top
 Profile  
 
 Post subject: Re: Lazy loading VS persistent storage decoupling
PostPosted: Tue May 26, 2009 11:07 am 
Newbie

Joined: Tue Aug 07, 2007 12:46 pm
Posts: 4
Running all business code *within* a Hibernate transaction/Session doesn't necessarily mean that your business code needs to be aware of this fact. This can be easily achieved with AOP using Spring or AspectJ. Thus, coupling is not an issue, and becomes more of an implementation/configuration detail.


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.