use of org.eclipse.persistence.eis.mappings.EISCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class DynamicXMLMetadataSource method createJAXBProperty.
/**
* Create a JAXB property for a particular mapping.
* This will only create JAXBProperties for mappings that are virtual - either because their
* parent object is a dynamic class, or because the owning static class has virtual properties
*/
private JAXBElement<XmlElement> createJAXBProperty(DatabaseMapping mapping, ObjectFactory objectFactory, JavaType owningType, boolean isDynamic) {
if (!mapping.getAttributeAccessor().isVirtualAttributeAccessor() && !isDynamic) {
return null;
}
XmlElement xmlElement = new XmlElement();
xmlElement.setJavaAttribute(mapping.getAttributeName());
if (mapping.isObjectReferenceMapping()) {
xmlElement.setType(((ObjectReferenceMapping) mapping).getReferenceClassName());
} else if (mapping.isCollectionMapping()) {
if (mapping.isEISMapping()) {
// It will be fine for simple collections
if (mapping instanceof EISCompositeDirectCollectionMapping) {
xmlElement.setContainerType(mapping.getContainerPolicy().getContainerClassName());
} else if (mapping instanceof EISCompositeCollectionMapping) {
xmlElement.setContainerType(mapping.getContainerPolicy().getContainerClassName());
xmlElement.setType(((EISCompositeCollectionMapping) mapping).getReferenceClassName());
}
} else {
xmlElement.setType(((CollectionMapping) mapping).getReferenceClassName());
xmlElement.setContainerType(mapping.getContainerPolicy().getContainerClassName());
}
} else {
xmlElement.setType(mapping.getAttributeClassification().getName());
}
if (mapping.getAttributeAccessor().isVirtualAttributeAccessor()) {
VirtualAttributeAccessor jpaAccessor = (VirtualAttributeAccessor) mapping.getAttributeAccessor();
if (owningType.getXmlVirtualAccessMethods() == null) {
XmlVirtualAccessMethods virtualAccessMethods = new XmlVirtualAccessMethods();
virtualAccessMethods.setGetMethod(jpaAccessor.getGetMethodName());
virtualAccessMethods.setSetMethod(jpaAccessor.getSetMethodName());
owningType.setXmlVirtualAccessMethods(virtualAccessMethods);
} else if (!owningType.getXmlVirtualAccessMethods().getGetMethod().equals(jpaAccessor.getGetMethodName())) {
XmlAccessMethods accessMethods = new XmlAccessMethods();
accessMethods.setGetMethod(jpaAccessor.getGetMethodName());
accessMethods.setSetMethod(jpaAccessor.getSetMethodName());
xmlElement.setXmlAccessMethods(accessMethods);
}
}
return objectFactory.createXmlElement(xmlElement);
}
Aggregations