-->
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: Using Hibernate w/ Web Services: Best practices?
PostPosted: Tue Jun 05, 2007 12:06 am 
Newbie

Joined: Mon Jun 04, 2007 11:49 pm
Posts: 1
We are planning to move our user interface to Flex as our applications needs that kind of user interface. To use flex, you have to expose your backend via Web Services (Java Remoting is out for us because of cost). However, our entire backend is Hibernate based and they cannot be simply returned back not only because of proxy serialization/deserialization issues but also, that serializing one object could serialize the entire database!

One solution is to use valueobjects and selectively populate them but I feel there must be a better solution.

I would like to know if others have faced this problem and how they have handled it.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 06, 2007 6:24 am 
Newbie

Joined: Mon Jan 22, 2007 3:45 pm
Posts: 9
You should not transmit your domain objects (hibernate objects) via webservices. In a typical Hibernate Object Model there is much data which is only used internally or is not necessary for the client. Note, that transferring data via web services is very inefficient, and you should only transfer data which is really needed by the client.

You have to define a separate object layer of DataTransfer Objects. Those DTOs can but need not have all properties of the domain objects. Here you can cut special associations that would otherwise cause the whole database to be transferred.

The advantage of this approach is much more flexibility and the client of the web-service is decoupled of your domain objects. This results in much cleaner system architecture. You can control effectively which data is transferred to the client.

The disadvantage is to spend additional time to create the DTOs and perform the mapping between the domain objects and the DTOs. But for this task there are many possibilities to create some generic mappers (which use reflection internally) that have to be written only once.


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.