quaylar
quaylar

Reputation: 2635

JAXB-ElipseLink: Preventing marshalling of inherited property

Again i am having an EclipseLink 2.3 marshalling-usecase that seems to be quite trivial but not working as expected:

I have an abstract base class which defines a property getX(). I have several child-classes derived from this base-class that inherit this property.

On marshalling the child-classes this property is marshalled as well for every child-class. However, for one specific child-class i want to prevent marshalling of this property.

I tried:

  1. @Override this property in the child-class and setting it @XmlTransient
  2. Specifying <xml-transient java-property="X"> in the oxm.xml for the child-class.

Both to no avail, the property is always marshalled - how is this supposed to work?

Upvotes: 2

Views: 432

Answers (1)

quaylar
quaylar

Reputation: 2635

Alright, this is how i solved it:

Make the abstract base class @XmlTransient, this will result in all properties/fields being treated as members of the child-classes. Then i marked X @XmlTransient in the child class in which i did not want it to be marshalled.

Im wondering if there is an alternative to this, in case one is not capable of setting the base class transient - for whatever reason.

Ideas?

Upvotes: 2

Related Questions