-->
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.  [ 3 posts ] 
Author Message
 Post subject: Command pattern to avoid LazyInitializationException
PostPosted: Wed Nov 14, 2007 5:09 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
Has any one implemented command pattern to lazy load object associations and collections in 3-tier application using command pattern? I have referred the book "Java Persistence with Hibernate".

It will be great if you can refer me to an working example. In my application, presentation tier access business/data tier via a proxy. So I can't use a OSIV (Open Session In View) pattern.

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 9:08 am 
Beginner
Beginner

Joined: Fri Apr 20, 2007 10:48 am
Posts: 49
Location: France
Hi sjhyam,

It is a good thing that you don't use OSIV, all the time the hibernate session is open, you are blocking a precious sql Connection instance. The best way to do things is to load relationships you'll need in the business (controller) layer. If you want to factorize some loading methods to be used by many views, the best way is to pass a String[] argument containing all needed dependencies to your business layer. If a command pattern was able to resolve the problem, I think it'd be directly on the hibernate site for a while. Hibernate is an "old" product, no more best practices are to be descovered or invented.

Regards,
Zied Hamdi

_________________
Regards,
Zied Hamdi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 20, 2007 11:56 am 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
Zied,

I have implemented the same approach. I am sending the eager loaded object to business layer first. Then on demand I am reading the lazy loaded properties with a separate business method. But this way, I have to instruct the other person to look different methods to load data. I am still trying to implement a factory based approach to load the data.

As of now i have solved my problem with a temp solution. But looking for more efficient solution.

Thanks
Shyam


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