-->
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.  [ 9 posts ] 
Author Message
 Post subject: How to populate a DTO from a POJO ??
PostPosted: Tue Jan 18, 2005 2:16 am 
Regular
Regular

Joined: Sat May 15, 2004 4:27 am
Posts: 79
Hi all,

i am working in application where i have to create DTOs of my hibernate beans (POJO) for the other layers. The others layers can't
manipulate POJO directly just DTO. So, i am looking for a function which can make the same work like the populate or copyProperties
of the commons.BeanUtils. And we noticed another trouble. We don't know how to break the hibernate cycle copy. I mean when you
have some relationships father/child :

class Father() {
//some properties
Set chils = new HashSet();

....
}

class Child() {
//some properties
Father father;

}

Do we have to delete the father property in the child DTO too ? I hope you understand me.
Bye.

-- Sebastien --


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 3:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i don't understand....an example would be good.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 4:28 am 
Regular
Regular

Joined: Sat May 15, 2004 4:27 am
Posts: 79
For example i have DTOs for my father and child classes :

class FatherDTO() {
//some properties
Object[] childs = null;

}

class ChildDTO() {
//some properties
FatherDTO father;

}

Noticed i am using Object[] array instead of Set because my DTOs are used in my Axis web services. Morever
i don't know how to map a Set in Axis wsdd. So how can i do for populating
my DTOs with a POJO. I am looking for this king of function :

Father pojoFather = hibernateSession.load(Father.class, fatherId);
FatherDTO dtoFather = new FatherDTO();
copyDTOForPOJO(dtoFather , pojoFather );

Max, do you what i mean now ? We make a function which uses reflexion but
the function is cycling because the relationship between a father and a chid.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 4:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well then you just need to write a function that can handle cycles ,)

sorry - i don't know from the top of my head something that does this automatically.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 4:59 am 
Regular
Regular

Joined: Sat May 15, 2004 4:27 am
Posts: 79
Can i delete all the relationships for avoiding the cycles ? I find this solution too hard because i am going
to delete all the databases constraints.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 5:10 am 
Regular
Regular

Joined: Sat May 15, 2004 4:27 am
Posts: 79
Sorry i noticed I post the wrong question. How can manage relationship
without using the Set object in the Father ?? For sample, the framework
Torque don't offer navigation both Father and Child. The Child can see
its father. But the Father can't see the its childs :

class Father() {
//Set childs; don't exist in Torque

}

class Child {
Father father;

}

Is it possible to generate that in Hibernate ? I am using Middlegen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 5:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - just make the relationship unidirectional.

Meaning don't generate the <set> mapping.....can't remember how that is done in middlegen..David?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 1:17 pm 
Regular
Regular

Joined: Sat May 15, 2004 4:27 am
Posts: 79
I noticed that with Middlegen you can specify the relationship navigation. I am very happy to know that
because we can use right now our copy properties function.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
For any readers etc. Middlegen can change the association attributes, multiplicity and activate/deactive direction using the mouse and keyboard. You hold either shift or cntrl and click then end of the relationship graphical line that you wish to change.


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