-->
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.  [ 1 post ] 
Author Message
 Post subject: Map Transfer Objects from and to persisted business objects
PostPosted: Sun Mar 30, 2008 2:08 pm 
Newbie

Joined: Tue Jan 29, 2008 6:37 pm
Posts: 9
I'm trying to figure out how to apply transfer objects in a Hibernate application where there is remote client server communication.
Suppose I have an object persisted in the database, a user modifies it and a transfer object with the modified data is returned to the backend, then its not so simple to map this to a business object.

For example when this Parent TO also has child TO's then the mapping function would have to do a lookup of the existing parent and child BO's, copy properties and persist those objects.

But I would like to create clean mapper classes that map the data of the TO to the BO in hte following way:

Code:
Parent parent = new Parent();
// copy properties from parentTo
for(ChildTo childTo : parentTo.getChildren()) {
    Child child = new Child();
    // copy all properties and set the parent
}
return parent;


That way I would simply make one call to hibernate, such as a merge or saveOrUpdate (but which one would I best use? because merge works for some things while saveOrUpdate for others)
But the thing is, if I try it out like this I get NonUnique exceptions because there is already a row with that ID :(

In short I would like to know how one should implement the persistance / synchrtonisation of data with hibernate when using transfer objects and mapping them from and to business objects , because I seem to find little usefull info about it :s


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.