Answer the question
In order to leave comments, you need to log in
How does inheritance work in classes for JAXB xml serialization?
Hello.
Tell me how inheritance works in classes for JAXB xml serialization.
Those. i have class MySuperXml:
@XmlRootElement(name = "super-xml")
@XmlSeeAlso(OtherSuperXml.class)
public class MySuperXml {
private List<Long> numbers;
}
public class OtherSuperXml extends MySuperXml {
private List<String> names;
}
Answer the question
In order to leave comments, you need to log in
They were probably just added to names. Still don't want to add annotations for numbers and names? I don't even know how it will be represented in XML without them.
For example, this is how you can do it:
@XmlRootElement(name = "super-xml")
@XmlSeeAlso(OtherSuperXml.class)
public class MySuperXml {
@XmlElement(name = "number")
private List<Long> numbers;
}
@XmlRootElement(name = "other-super-xml")
public class OtherSuperXml extends MySuperXml {
@XmlElement(name = "name")
private List<String> names;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question