I tried @blaise-doughan's suggestion and added the @XmlTransient
annotation to top of my abstract base class.
With my environment (so my product depends something strictly), the jaxb-api library says "The annotation @XmlTransient
is disallowed for this location" because of the version of it high probably older than 2.1. I realized that when I tried to adding the annotation with a new test class-path which contains version >=2.1, so it allows to defining it top of a class.
So let me get straight to the point, I suggest below method in order to get rid of the type fields which appears on responses which are building and marshaling from extended classes.
I only added @XmlDiscriminatorNode("")
to top of my base class and I supposed that you are using the EclipseLink MOXy:
import org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode;
@XmlDiscriminatorNode("")
public abstract class Base {
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
As a summary you can use @XmlTransient
if you have the jaxb-api version greater than 2.1 or use my method if you have EclipseLink MOXy.