Given the following classes:
@XmlRootElement(name = "parent")
class Parent {
private Child child;
// What annotation goes here
public Child getChild() {
return child;
}
public void setChild(Child child) {
this.child = child;
}
}
class Child {
private Integer age;
@XmlElement(name = "age")
public Integer getAge() {
return age;
}
public void setAge(Integer Age) {
this.age = age;
}
}
What annotation do I need to add (where the comment is) to get the following xml:
<parent>
<age>55</age>
</parent>
I just made the specific example off the top of my head so having the tag appear where it is probably doesn’t make sense. But what I really want to know is how to do a pass-through to the Child class. Essentially its easy to do the mapping for the following (which I DON’T want):
<parent>
<child>
<age>55</age>
</child>
</parent>
prints