use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class SingleElementKeyUsingMapProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("employee");
// create id mapping
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
descriptor.addMapping(idMapping);
// create name mapping
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("name/text()");
descriptor.addMapping(nameMapping);
// create address mapping
XMLCollectionReferenceMapping addressMapping = new XMLCollectionReferenceMapping();
addressMapping.setAttributeName("addresses");
addressMapping.setReferenceClass(Address.class);
addressMapping.useMapClass(HashMap.class, "getKey");
addressMapping.addSourceToTargetKeyFieldAssociation("address-id/text()", "@aid");
descriptor.addMapping(addressMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class SingleElementKeyProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("employee");
// create id mapping
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
descriptor.addMapping(idMapping);
// create name mapping
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("name/text()");
descriptor.addMapping(nameMapping);
// create address mapping
XMLCollectionReferenceMapping addressMapping = new XMLCollectionReferenceMapping();
addressMapping.useCollectionClass(ArrayList.class);
addressMapping.setAttributeName("addresses");
addressMapping.setReferenceClass(Address.class);
addressMapping.addSourceToTargetKeyFieldAssociation("address-id/text()", "@aid");
descriptor.addMapping(addressMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class SingleElementKeyWithGroupingProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("employee");
// create id mapping
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
descriptor.addMapping(idMapping);
// create name mapping
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("name/text()");
descriptor.addMapping(nameMapping);
// create address mapping
XMLCollectionReferenceMapping addressMapping = new XMLCollectionReferenceMapping();
addressMapping.useCollectionClass(ArrayList.class);
addressMapping.setAttributeName("addresses");
addressMapping.setReferenceClass(Address.class);
addressMapping.addSourceToTargetKeyFieldAssociation("addresses/address-id/text()", "@aid");
descriptor.addMapping(addressMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class NoRefClassProject method getCustomerDescriptor.
private XMLDescriptor getCustomerDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Customer.class);
XMLObjectReferenceMapping addressMapping = new XMLObjectReferenceMapping();
addressMapping.setAttributeName("address");
addressMapping.addSourceToTargetKeyFieldAssociation("address-id/text()", null);
xmlDescriptor.addMapping(addressMapping);
XMLCollectionReferenceMapping phoneNumbersMapping = new XMLCollectionReferenceMapping();
phoneNumbersMapping.setAttributeName("phoneNumbers");
phoneNumbersMapping.addSourceToTargetKeyFieldAssociation("phone-number-id/text()", null);
phoneNumbersMapping.getContainerPolicy().setContainerClass(ArrayList.class);
xmlDescriptor.addMapping(phoneNumbersMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class CompositeElementKeyProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("employee");
// create id mapping
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
descriptor.addMapping(idMapping);
// create name mapping
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("name/text()");
descriptor.addMapping(nameMapping);
// create address mapping
XMLCollectionReferenceMapping addressMapping = new XMLCollectionReferenceMapping();
addressMapping.useCollectionClass(ArrayList.class);
addressMapping.setAttributeName("addresses");
addressMapping.setReferenceClass(Address.class);
addressMapping.addSourceToTargetKeyFieldAssociation("address/id-city/text()", "city/text()");
addressMapping.addSourceToTargetKeyFieldAssociation("address/id-zip/text()", "zip/text()");
descriptor.addMapping(addressMapping);
return descriptor;
}
Aggregations