Is there a way to tweak the @XmlTransient JPA2.0 annotation so that it will block the JAXB mechanism only when the Java-Object is serialized to xml and not when the incoming XML is converted to a java object?
Background: I have a REST api that speaks XML. There is an endpoint for creating a new Attachment. Since we are talking about attachment, there is a byte field [] in this class. In the optional attachment lists, I do not want to deliver the contents of the byte [] of each attachment.
@Entity
@XmlRootElement
public class Attachment {
private String name;
private String mimeType;
private byte[] dataPart;
public String getName() {
return name;
}
public void setName( String name ) {
this.name = name;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType( String mimeType ) {
this.mimeType = mimeType;
}
public byte[] getDataPart() {
return dataPart.clone();
}
public void setDataPart( byte[] dataPart ) {
this.dataPart = dataPart.clone();
}
}
So, when I mark getDataPart () with an XmlTransient, the incoming byte [] data is ignored and set to null -> it is lost. Does anyone know how to indicate the direction of XmlTransient?
source
share