How do I prevent JAXB from binding superclass methods of the @XmlRootElement when marshalling?
Posted
by Matt Fisher
on Stack Overflow
See other posts from Stack Overflow
or by Matt Fisher
Published on 2009-03-18T20:01:04Z
Indexed on
2010/06/18
5:03 UTC
Read the original article
Hit count: 332
I have a class that is annotated as the @XmlRootElement
with @XmlAccessorType(XmlAccessType.NONE)
. The problem that I am having is that the superclass's methods are being bound, when I do not want them to be bound, and cannot update the class. I am hoping there is an annotation that I can put on the root element class to prevent this from happening.
Example:
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class Person extends NamedObject {
@XmlElement
public String getId() { ... }
}
I would expect that only the methods annotated @XmlElement
on Person
would be bound and marshalled, but the superclass's methods are all being bound, as well. The resulting XML then has too much information.
How do I prevent the superclass's methods from being bound without having to annotate the superclass, itself?
© Stack Overflow or respective owner