usesBatchReadingMapping.setSetMethodName("setUsesBatchReading");
usesBatchReadingMapping.setXPath(getPrimaryNamespaceXPath() + "batch-reading/text()");
usesBatchReadingMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(usesBatchReadingMapping);
XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping();
containerPolicyMapping.setAttributeName("containerPolicy");
containerPolicyMapping.setGetMethodName("getContainerPolicy");
containerPolicyMapping.setSetMethodName("setContainerPolicy");
containerPolicyMapping.setReferenceClass(ContainerPolicy.class);
containerPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "container");
descriptor.addMapping(containerPolicyMapping);
XMLCompositeObjectMapping indirectionPolicyMapping = new XMLCompositeObjectMapping();
indirectionPolicyMapping.setReferenceClass(IndirectionPolicy.class);
// Handle translation of NoIndirectionPolicy -> null.
indirectionPolicyMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
IndirectionPolicy policy = ((ForeignReferenceMapping)object).getIndirectionPolicy();
if (policy instanceof NoIndirectionPolicy) {
return null;
}
return policy;
}
public void setAttributeValueInObject(Object object, Object value) {
IndirectionPolicy policy = (IndirectionPolicy)value;
if (value == null) {
policy = new NoIndirectionPolicy();
}
((ForeignReferenceMapping)object).setIndirectionPolicy(policy);
}
});
indirectionPolicyMapping.setAttributeName("indirectionPolicy");
indirectionPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "indirection");
descriptor.addMapping(indirectionPolicyMapping);
XMLCompositeObjectMapping selectionQueryMapping = new XMLCompositeObjectMapping();
selectionQueryMapping.setAttributeName("selectionQuery");
selectionQueryMapping.setGetMethodName("getSelectionQuery");
selectionQueryMapping.setSetMethodName("setSelectionQuery");
selectionQueryMapping.setReferenceClass(ReadQuery.class);
selectionQueryMapping.setXPath(getPrimaryNamespaceXPath() + "selection-query");
descriptor.addMapping(selectionQueryMapping);
XMLDirectMapping referenceTableMapping = new XMLDirectMapping();
referenceTableMapping.setAttributeName("referenceTableName");
// CR#2407 Call getReferenceTableQualifiedName that includes table qualifier.
referenceTableMapping.setGetMethodName("getReferenceTableQualifiedName");
referenceTableMapping.setSetMethodName("setReferenceTableName");
referenceTableMapping.setXPath(getPrimaryNamespaceXPath() + "reference-table/text()");
descriptor.addMapping(referenceTableMapping);
XMLCompositeObjectMapping directFieldMapping = new XMLCompositeObjectMapping();
directFieldMapping.setAttributeName("directField");
directFieldMapping.setGetMethodName("getDirectField");
directFieldMapping.setSetMethodName("setDirectField");
directFieldMapping.setXPath(getPrimaryNamespaceXPath() + "direct-field");
directFieldMapping.setReferenceClass(DatabaseField.class);
descriptor.addMapping(directFieldMapping);
XMLCompositeCollectionMapping sourceToReferenceKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
sourceToReferenceKeyFieldAssociationsMapping.setReferenceClass(Association.class);
// Handle translation of foreign key associations to hashtables.
sourceToReferenceKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
List sourceFields = ((DirectCollectionMapping)object).getSourceKeyFields();
List referenceFields = ((DirectCollectionMapping)object).getReferenceKeyFields();
List associations = new ArrayList(sourceFields.size());
for (int index = 0; index < sourceFields.size(); index++) {
associations.add(new Association(referenceFields.get(index), sourceFields.get(index)));
}
return associations;
}
public void setAttributeValueInObject(Object object, Object value) {
DirectCollectionMapping mapping = (DirectCollectionMapping)object;
List associations = (List)value;
mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
mapping.setReferenceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
Iterator iterator = associations.iterator();
while (iterator.hasNext()) {
Association association = (Association)iterator.next();
mapping.getSourceKeyFields().add((DatabaseField)association.getValue());
mapping.getReferenceKeyFields().add((DatabaseField)association.getKey());
}
}
});
sourceToReferenceKeyFieldAssociationsMapping.setAttributeName("sourceToReferenceKeyFieldAssociations");
sourceToReferenceKeyFieldAssociationsMapping.setXPath(getPrimaryNamespaceXPath() + "reference-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
descriptor.addMapping(sourceToReferenceKeyFieldAssociationsMapping);
XMLCompositeObjectMapping valueConverterMapping = new XMLCompositeObjectMapping();
valueConverterMapping.setAttributeName("valueConverter");
valueConverterMapping.setGetMethodName("getValueConverter");
valueConverterMapping.setSetMethodName("setValueConverter");
valueConverterMapping.setXPath(getPrimaryNamespaceXPath() + "value-converter");
valueConverterMapping.setReferenceClass(Converter.class);
descriptor.addMapping(valueConverterMapping);
XMLCompositeObjectMapping historyPolicyMapping = new XMLCompositeObjectMapping();
historyPolicyMapping.setAttributeName("historyPolicy");
historyPolicyMapping.setGetMethodName("getHistoryPolicy");
historyPolicyMapping.setSetMethodName("setHistoryPolicy");
historyPolicyMapping.setReferenceClass(HistoryPolicy.class);
historyPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "history-policy");
descriptor.addMapping(historyPolicyMapping);
return descriptor;
}