-->
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: Usagepattern for Hibernate or To use or not to use DTO?
PostPosted: Fri Apr 15, 2005 6:58 am 
Newbie

Joined: Fri Apr 15, 2005 6:40 am
Posts: 1
Hello,

I'm currently developing a standalone application which is based on a server component and a rich client component. For the Datalayer I want to use Hibernate.
I allready read the reference guide and looked at resources in the wiki but I couldn't find a definite answer to my question (maybe there is none!).
Normally I use a ValueObject or DTO pattern ( I will use the term valueobject interchangably for both also they have differences) to transfer my domainobjects to the client. This is a lot of coding especially when you have to handcode all valueobjects.
In this new application I would like to get rid of the valueobjects all together and simply pass the persistence objects directly to the client using attach and reattach semantics.
Also this sounds like a common approach I would like to evaluate the drawbacks first, so can anybody give me a hint why this approach should not be used?
Is there a hidden catch to passing the persistence classes to the client that I haven't stumbled across yet?

Using a generator approach for Valueobjects is a solution I know about, but having difficulties in the past with tools like that I try to avoid them so please do not mention such a solution.

Thanks for your help

Regards
Musk


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 15, 2005 7:48 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
I guess one of the hard parts would be dealing with lazy loading of associated entities.

By default, the latest hibernate (3) uses lazy loading for all associations. This can be overridden though. So, for each entity you'd have to work out the extent of the object graph that you wish to retrieve in the data layer, and either set those association to non-lazy explicitly in the mapping files, or design the data layer code to initialise them as required.

Changes to detached objects can also involve transactional problems, with the recommended hibernate solution being to use optimistic locking through versioning attributes on the entities (these are automatically handled by hibernate, I believe).

Those are the obvious problems I can think of, pretty sure there's others.


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.