-->
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.  [ 8 posts ] 
Author Message
 Post subject: Enable lazy loading, but disable transparent persistence
PostPosted: Tue Sep 21, 2004 12:49 pm 
Newbie

Joined: Tue Sep 21, 2004 12:39 pm
Posts: 18
From my reading so far, I have not been eble to determine if its possible to have an object enabled for lazy loading, but prevent transparent persistence.

My real issue is, I would like to keep the functionality of lazy loading, for when I pass my objects to the UI. However, it might be too easy/tempting for my UI guys to manipulate the object on the JSP page, which from my understanding would transparently persist to the database when the session is eventually closed by the servlet filter.

If my data access layer could return "locked" objects that can still be lazy loaded but not updated, I think it would be a real win win situation.

TIA
David


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You should give your user interface layer exactly the graph of objects it needs and not use magic lazy loading and unclear transaction boundaries (even if it would be available).

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 1:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well probably you should just adjust the visibilitiy of your get/set methods accordingly ...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 2:09 pm 
Newbie

Joined: Tue Sep 21, 2004 12:39 pm
Posts: 18
michael wrote:
Well probably you should just adjust the visibilitiy of your get/set methods accordingly ...


Changing the visibility would work to prevent the UI from setting values, but are required for the business layer.

_________________
David Launen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 2:13 pm 
Newbie

Joined: Tue Sep 21, 2004 12:39 pm
Posts: 18
christian wrote:
You should give your user interface layer exactly the graph of objects it needs and not use magic lazy loading and unclear transaction boundaries (even if it would be available).


So does this mean that lazy loading should never be used at the presentation layer?

_________________
David Launen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 2:19 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Well, I'd probably use lazy loading in small two-tiered web applications with a ThreadLocal and Interceptor pattern for Session and Transaction management. In all other cases I'd return the correct subgraph from my service layer, even consider DTOs and/or automatic assemblers.

This is a question of application design and there are many best practices but no "you are right I am wrong"-kind of answers for everything.

I really recommend Hibernate in Action or one of our trainings for architectural questions that go beyond regular Hibernate usage. If you search the forum you'll find many discussions, but this stuff is much easier to communicate with a full example (as in the book) or in person.

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 2:22 pm 
Newbie

Joined: Tue Sep 21, 2004 12:39 pm
Posts: 18
christian wrote:
Well, I'd probably use lazy loading in small two-tiered web applications with a ThreadLocal and Interceptor pattern for Session and Transaction management. In all other cases I'd return the correct subgraph from my service layer, even consider DTOs and/or automatic assemblers.

This is a question of application design and there are many best practices but no "you are right I am wrong"-kind of answers for everything.

I really recommend Hibernate in Action or one of our trainings for architectural questions that go beyond regular Hibernate usage. If you search the forum you'll find many discussions, but this stuff is much easier to communicate with a full example (as in the book) or in person.


Thanks, I actually have my Hibernate in Action book right beside me.

_________________
David Launen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 6:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Things like access controll to methods is really something your code should be doing IMHO. Either use method visibility (package or something), educate your co-programmers, use some static code checking tools, whatever.


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