I have a class like this:
@XmlRootElement(name = "PricingGroup")
public class PricingGroup {
...
@XmlAttribute(name = "partyName")
@XmlJavaTypeAdapter(CustomerGroupRelationships.Adapter.class)
private List<BilltoCustomer> billtoCustomers = new ArrayList<BilltoCustomer>();
@XmlAttribute(name = "partyName")
@XmlJavaTypeAdapter(PartyNames.Adapter.class)
private PartyName partyName;
...
}
It seems JAXB can’t map two @XmlJavaTypeAdapters for one attribute (here partyName). If I comment out either the annotations on billtoCustomers or the annotations on partyName, the other member variable is read from XML without problems.
How can I get both values at the same time?
You could map one of the properties (
partyName) and then use anafterUnmarshalevent to derive the other property (billToCustomers):