Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RESTful service design ?

 
Mag Wells
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mag,
I'mg going to move this out of our ORM forum since you have the database part done.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic