After hours of try and error I want ask here if someone could help me to solve my problem.
Scenario:
UUIDIdentified
that is Superclass of all persistence Classes (It provides the JPA @ID
) it is in Projekt CommonWithin the ServiceA Class is an Method: public List<DTO> getData(UUIDIdentified value);
The Server reads some Objects that are all subtypes of UUIDIdentified, and the goal is to pack the Objects in DTOs.
A DTO would look like:
@XmlAccessorType(XmlAccessType.FIELD)
public class DTO{
private static final long serialVersionUID = 1L;
@XmlElement(name = "uuididentified")
UUIDIdentified object;
public UUIDIdentified getObject() {
return object;
}
public void setObject(final UUIDIdentified object) {
this.object = object;
}
}
If i look into the SOAP response, I see that there is no Data in the <uuididentified>
tag. My understanding of JAXB isnt so well, but as I understand the "real" instances of the UUIDIdentified and their types are unknown to the JAXBContext.
I could solve this by adding @XmlSeeAlso({TypeA.class,TypeB.class})
to the UUIDIdentified
class (I reckon). But that is what I cant because if i would do so, the Project Common would depend on Projects PersistenceA/B.
How can I solve this. How can I say to JAXB(Maybe in a xml config file) that it have to add ClassA/B to the JAXBContext as it adds UUIDIdentified?
I tried some things like jaxb.index files, ObjectFactorys, @XmlSeeAlso on the SEI but I dont know if that is the right way.
After I tried to marshall/unmarshal the object by my self, with @XmlJavaTypeAdapter
i faced the root of the problem. It wasn't anything with the JAXBContect. The Problem was my Object was a Hibernate-Envers read object, and envers produces Proxy Objects(even if they are EAGER).
So the marshaller could not extract the real value from the Proxy object.