I do not think this is a JAXB problem, as the following model will work:
package forum10617267;
import java.io.Serializable;
import java.util.*;
import javax.xml.bind.annotation.*;
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class User implements Serializable {
@XmlTransient
private Set<History> history = new HashSet<History>();
@XmlElement
private Set<History> getXmlHistory() {
return history;
}
private void setXmlHistory(final Set<History> aHistory) {
this.history = aHistory;
}
}
The problem you see is the result of your logic in get / set methods. Since your field is valuesnot initialized, I'm not sure how I CustomSetcan update it.
package forum10617267;
import java.io.Serializable;
import java.util.*;
import javax.xml.bind.annotation.*;
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class User implements Serializable {
@XmlTransient
private Set<Values> values;
@XmlElement
private Set<History> getXmlHistory() {
return new CustomSet<Values, History>(values);
}
private void setXmlHistory(final Set<History> aHistory) {
this.values = new HashSet<Values>();
}
}
source
share