-->
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.  [ 5 posts ] 
Author Message
 Post subject: Architectural question: Domain objects as DTO's ?
PostPosted: Tue Jan 11, 2005 3:38 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 12:44 am
Posts: 25
Hello all,

I am posting this msg here coz I didn't find a better place to post this architectural question.

The architecture is like Struts->Service Locator->Session Facade->Business Objects->ORM->Database. For transferring data across layers we need DTO's that are again simple POJO's as Hibernate domain objects. Can we use the Hibernate domain objects as DTO's in an application ?

Tommorrow, third party clients can also connect to the application. In that case they might be exposed to the domain objects if we use them. Is that okay ?

If yes, some of the members of the DTO/domain objects need not be matched with any database field. How can we accompalish this ?


Cheers,

Nitin Dubey


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 6:46 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
We do not recommend the DTO pattern but of course you can still use it the same way you did before.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 7:49 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 12:44 am
Posts: 25
If DTO is not recommended what is the other option ? We still need to pass some data from presentation layer to the business layer ? Any other pattern you want to recommend ?

Regards,

Nitin Dubey


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 8:33 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can use your domain objects or a data transfer map. This is outside of the scope of Hibernate, use whatever you like.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 10:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The practical implication of passing your domain objects outside the scope of the Hibernate session (especially a concern where third-parties may be using these) is that it does present a potential problem of lazy initialization issues if you used that feature.

Consider a Conpany object with a lazy collection of Employees. If you send that Company outside the scope of the session with the Company.employees still lazy, you will not be able to initialize that employee collection.

This is not "detrimental", just something that needs to be considered.


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