Ho questo problema nel tentativo di unmarshall json dal resto webservice (cxf). Sto usando JAXB e EclipseLink.Unmarshalling collezione JAXB quando si utilizza IDResolver in mancanza perché IDResolver Object come tipo di destinazione
L'entità viene mappato così:
@Entity
@Table(name = "service_pkg_service", schema = "MD")
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ServicePkgService extends DatabaseModel implements java.io.Serializable {
@Transient
@XmlIDREF
private Set<ChannelPkgService> channelPkgServices = new HashSet<ChannelPkgService>();
}
@Entity
@Table(name = "channel_pkg_service", schema = "MD")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class ChannelPkgService extends DatabaseModel implements java.io.Serializable{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "CHANNEL_PKG_ID")
@XmlID
@XmlAttribute
private String id;
}
Ho una classe che estende IDResolver, così posso generare un'entità base al suo ID.
public class EntityIDResolver extends IDResolver{
@Override
public void bind(String id, Object obj) throws SAXException {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Callable<?> resolve(final String id, Class targetType) throws SAXException {
}
}
Ho problema unmarshalling JSON come questo "channelPkgService": [1,2,3], la classe di targetType è java.lang.Object
ho letto questo https://github.com/javaee/jaxb-v2/issues/546, e ha creato un wrapper per gestire questo.
public class ChannelPkgServiceWrapper extends HashSet<ChannelPkgService>{
}
Sinse Ho un sacco di questi casi e non voglio creare un sacco di involucri, c'è un modo più generico per gestire questo?
dimenticare le versioni utilizzate:
- cxf.version: 2.3.6
- EclipseLink: 2.3.0
- JAXB-impl-2.1.13.jar (barattolo contenente Lister.class che sta facendo il lavoro effettivo per ottenere il tipo corretto.)