aspose file tools*
The moose likes Web Services and the fly likes RESTful service design ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "RESTful service design ?" Watch "RESTful service design ?" New topic
Author

RESTful service design ?

Mag Wells
Ranch Hand

Joined: Jun 02, 2010
Posts: 38
I am bit confused as to where I should be posting this question.
The thing is -
1. I have figured out my database. Multiple relations and many to one mapping etc.
2. Reverse engineered with Hibernate tools to generate the POJOs.

3. Now, I have a Spring (RESTful) webapp on top of it. So is it a good idea to have different pojo representing the xml to be exposed or used the one's generated by hibernate ?
4. What are the details to be shown in the xml.
For example I have movie table. It has many ppl, and other such info related to it. Obviously, this table is going to have foreign keys to other such tables. Now when I have to display movie information,
I cannot just list the id(foreign keys) in the xml. It has to have a name for example of an actor.

How is this movie object going to look like ?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30965
    
158

Mag,
I'mg going to move this out of our ORM forum since you have the database part done.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30965
    
158

Mag Wells wrote:3. Now, I have a Spring (RESTful) webapp on top of it. So is it a good idea to have different pojo representing the xml to be exposed or used the one's generated by hibernate ?

I would use a different POJO. One reason is that if the database or back end POJO changes, I want the web services to stay backward compatible. This is subjective of course.

Mag Wells wrote:4. What are the details to be shown in the xml....How is this movie object going to look like ?

What is the requirement? What is the web service meant to do?
Mag Wells
Ranch Hand

Joined: Jun 02, 2010
Posts: 38
I guess my question is bit confusing.

Precisely what pattern do I use ?
so I have POJOs for hibernate, but I want to run xstream and generate xml output. For example I have a Account POJO mapped to Account table. When I read an account I want to display it in xml format. Thing I do now is run xstream on it. But it generates some un-necessary ouput like




I don't need this extra cachedsize, owner, initialized, dirty stuff. Those are hibernate details. So you suggest creating another JavaObject for representing an xml output ?

What is the design pattern normally followed. I don't want to end up writing all the classes. Is there any tool that does that ?

Mag Wells
Ranch Hand

Joined: Jun 02, 2010
Posts: 38

Mag Wells wrote:4. What are the details to be shown in the xml....How is this movie object going to look like ?

What is the requirement? What is the web service meant to do?


Well does that mean I have to write the POJO for xmlview ? Is there any tool that would generate a POJO for xmlview from Hibernate POJO or something similar to getter-setter functionality in eclipse ?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: RESTful service design ?