This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes Marshalling XML with Spring (How to handle referenced classes) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Marshalling XML with Spring (How to handle referenced classes)" Watch "Marshalling XML with Spring (How to handle referenced classes)" New topic
Author

Marshalling XML with Spring (How to handle referenced classes)

Michael Bradshaw
Greenhorn

Joined: Feb 11, 2011
Posts: 5

If I want to marshall a class to XML, and that class contains a reference to another class, how do I ONLY put the ID of that subclass in the XML. My simple example of this appears below. Say I have 2 classes, Employee & Department:



Now suppose I’m building a RESTful interface and when I go to the URL http://www.mycompany.com/myApp/Employees/5
I want this to be displayed:


What is the best marshalling program in Spring to do this (JAXB, Castor, etc), and how do I do this? Does this have a name so that I can google for more information about it? Also, I would need to unmarshall the XML back to java, such that I get an employee with a reference to a department, but only the ID of the department would be filled.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Marshalling XML with Spring (How to handle referenced classes)
 
Similar Threads
Converting a Java Class to XML when Class contains Non-Primitive Types
xml experts help me SAX Parser in xml
problem with @FieldResult, mapping does not seem to work
database with jsp
what is the error in this program