use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class AttributeProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.addPrimaryKeyFieldName("id/@id1");
descriptor.addPrimaryKeyFieldName("id/@ns:id2");
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("ns", "urn:example");
descriptor.setNamespaceResolver(namespaceResolver);
XMLCompositeObjectMapping idMapping = new XMLCompositeObjectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("id");
idMapping.setReferenceClass(EmployeeID.class);
descriptor.addMapping(idMapping);
XMLObjectReferenceMapping managerMapping = new XMLObjectReferenceMapping();
managerMapping.setAttributeName("manager");
managerMapping.addSourceToTargetKeyFieldAssociation("manager/@fk1", "id/@id1");
managerMapping.addSourceToTargetKeyFieldAssociation("manager/@ns:fk2", "id/@ns:id2");
managerMapping.setReferenceClass(Employee.class);
descriptor.addMapping(managerMapping);
XMLCollectionReferenceMapping employeesMapping = new XMLCollectionReferenceMapping();
employeesMapping.setAttributeName("teamMembers");
employeesMapping.addSourceToTargetKeyFieldAssociation("team-member/@fk1", "id/@id1");
employeesMapping.addSourceToTargetKeyFieldAssociation("team-member/@ns:fk2", "id/@ns:id2");
employeesMapping.setReferenceClass(Employee.class);
descriptor.addMapping(employeesMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class CompositeElementKeySingleNodeProject 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.setUsesSingleNode(true);
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;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class SingleNodeProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.addPrimaryKeyFieldName("id/id1/text()");
descriptor.addPrimaryKeyFieldName("id/ns:id2/text()");
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("ns", "urn:example");
descriptor.setNamespaceResolver(namespaceResolver);
XMLCompositeObjectMapping idMapping = new XMLCompositeObjectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("id");
idMapping.setReferenceClass(EmployeeID.class);
descriptor.addMapping(idMapping);
XMLObjectReferenceMapping managerMapping = new XMLObjectReferenceMapping();
managerMapping.setAttributeName("manager");
managerMapping.addSourceToTargetKeyFieldAssociation("manager/@fk1", "id/id1/text()");
managerMapping.addSourceToTargetKeyFieldAssociation("manager/ns:fk2/text()", "id/ns:id2/text()");
managerMapping.setReferenceClass(Employee.class);
descriptor.addMapping(managerMapping);
XMLCollectionReferenceMapping employeesMapping = new XMLCollectionReferenceMapping();
employeesMapping.setAttributeName("teamMembers");
employeesMapping.addSourceToTargetKeyFieldAssociation("team-member/@fk1", "id/id1/text()");
employeesMapping.addSourceToTargetKeyFieldAssociation("team-member/ns:fk2/text()", "id/ns:id2/text()");
employeesMapping.setReferenceClass(Employee.class);
employeesMapping.setUsesSingleNode(true);
descriptor.addMapping(employeesMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class NestedAttributeKeyProject 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.setXPath("addresses");
addressMapping.setReferenceClass(Address.class);
addressMapping.addSourceToTargetKeyFieldAssociation("address-ref/@address-city", "city/text()");
addressMapping.addSourceToTargetKeyFieldAssociation("address-ref/@address-zip", "zip/text()");
addressMapping.setUsesSingleNode(false);
descriptor.addMapping(addressMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class SingleAttributeKeyProject 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-ids", "@aid");
addressMapping.setUsesSingleNode(true);
descriptor.addMapping(addressMapping);
return descriptor;
}
Aggregations