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.setReferenceClass(ReadQuery.class);
selectionQueryMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
if (((ForeignReferenceMapping)object).hasCustomSelectionQuery()) {
return ((ForeignReferenceMapping)object).getSelectionQuery();
}
return null;
}
public void setAttributeValueInObject(Object object, Object value) {
if ((value != null) && value instanceof ReadQuery) {
((ForeignReferenceMapping)object).setCustomSelectionQuery((ReadQuery)value);
}
}
});
selectionQueryMapping.setXPath(getPrimaryNamespaceXPath() + "selection-query");
descriptor.addMapping(selectionQueryMapping);
// delete-all query
XMLCompositeObjectMapping deleteAllQueryMapping = new XMLCompositeObjectMapping();
deleteAllQueryMapping.setAttributeName("deleteAllQuery");
deleteAllQueryMapping.setReferenceClass(ModifyQuery.class);
deleteAllQueryMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
boolean hasCustomDeleteAllQuery = ((EISOneToManyMapping)object).hasCustomDeleteAllQuery();
if (hasCustomDeleteAllQuery) {
return ((EISOneToManyMapping)object).getDeleteAllQuery();
} else {