Reputation: 6263
I am interested in not marshaling/unmarshaling the principal field of my A object. I have added XmlTransient
in different places but it still seem to marshal it.
Any ideas?
Here is class A:
@XmlRootElement(name = "A")
public class AImpl implements A, Serializable {
private String attrName;
private String attrValue;
@XmlTransient
private Object principal;
public class Adapter extends XmlAdapter<AImpl,A> {
public A unmarshal(AImpl v) { return v; }
public AImpl marshal(A v) { return (AImpl)v; }
}
public String getAttrName() {
return attrName;
}
public void setAttrName(String s) {
this.attrName = s;
}
public String getAttrValue() {
return attrValue;
}
public void setAttrValue(String s) {
this.attrValue = s;
}
@XmlTransient
public Object getPrincipal() {
return principal;
}
@XmlTransient
public void setPrincipal(Object o) {
this.principal = o;
}
}
Here is how I marshal it:
JAXBContext context = JAXBContext.newInstance(AImpl.class);
Marshaller m = context.createMarshaller();
m.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT,true);
m.marshal(al sw);)
Upvotes: 2
Views: 2367