I am using Jackson (jaxb) for JSON marshalling and unmarshalling.
For example here I have annotated address field XmlTransient because I don't want it to be mapped when person records are listed (Security and Speed concerns), address field is lazy anyway. But when a single person record is returned I want that address field to be mapped, but even fetching the address eagerly jaxb still doesn't map it. Is there any way that I can change this behaviour and map this field at runtime when the address field is annotated with @XmlTransient?
public class Person implements Serializable {
@Column(nullable = false, length = 50)
private String username;
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
private Address address;
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
@XmlTransient
public Address getAddress() {
return this.address;
}
public void setAddress(Address address) {
this.address = address;
}
}