-->
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.  [ 2 posts ] 
Author Message
 Post subject: Domain model objects vs. DTO
PostPosted: Wed Aug 25, 2004 10:47 am 
Newbie

Joined: Tue Aug 24, 2004 3:20 pm
Posts: 6
I'm a newbie to Hibernate, and have a simple design question for more seasoned Hibernate developers.

I have a set of domain model classes that heavily use lazy loading of associated entities, and I need an advice as to whether there is a way to use these domain model objects across the entire tiers without having to define separate DTOs.

According to section 6.5 (Lazy Initialization) in the Hibernate reference manual, access to the members of the lazily initialized/loaded collection must occur only within the transaction in which the refering entity is retrieved, which means that I can not simply pass the refering entity (or a handle on the collection) to the presentation layer, which would then subsequently access the members of the collection, since presentation layer doesn't (and shouldn't) manage transactions.

This brings me the question - should I really create DTO in the business service layer to copy the states of the persistent objects to some dummy in-memory datastructures before returning them back to the presentation layer? Is there some other way to solve this problem that avoids coping stuff all the time across presentation and business tiers?

Thanks for help.
/Jong


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 25, 2004 10:48 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You will find many discussions if you search the forum. If you are looking for the complete story, get Hibernate in Action.

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


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