-->
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: Copying an object graph
PostPosted: Wed Nov 19, 2003 8:31 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
This is my scenario:

My server has a load of persistent objects. However, I need the client to access the domain model, but I don't want to send persistent objects to the client. In fact, I cannot do this since I use WebServices (which lacks supports for stuff like Sets)

So I have a "shadow" class hierarchy that looks just like my persistent classes, except that Sets are java arrays, etc.

Is there an easy way to copy between the persistent and non-persistent object graph?

I guess I could look into the reflection / hibernate metadata API, but if there is a standard solution...

I guess I would also need to specify how much of the graph to copy.

Difficult problem?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 11:37 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I am not you will like it, but you can add some noise to model itself :

Set collection;

void setCollection(Set collection){

this.collection = collection;

}

MyObject[] getArray(){

return this.collection.toArray( new MyObject[]{} );

}

....

Map collections to DB and arrays to web methods.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 6:48 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
"I am not you will like it, but you can add some noise to model itself"

You're right: I don't like it ;-)

Besides, I (re)generate the persistent java classes using the hibernate tools, so that's out of the question anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 9:36 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Do you think it is better to have two domain models and copy data between models ?
I am not WebServices expert but I think it must be some way to provide custom type mappings and data transformations to return collection as array of objects.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 12:17 pm 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
No, there is no way to map sets and maps. .NET certainly doesn't support it, given a Java webservices server.

Besides, exposing persistent classes on any client is not a good design.


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.