• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Marshalling XML with Spring (How to handle referenced classes)

 
Greenhorn
Posts: 5
Hibernate Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic