protected ClassDescriptor buildTypedAssociationDescriptor() {
    ClassDescriptor descriptor = super.buildTypedAssociationDescriptor();

    XMLDirectMapping keyMapping = (XMLDirectMapping) descriptor.getMappingForAttributeName("key");
    keyMapping.setAttributeClassification(null);
    keyMapping.setGetMethodName("getKey");
    keyMapping.setSetMethodName("setKey");

    return descriptor;
  }
 @SuppressWarnings("unchecked")
 @Override
 public void handleSqlType(String sqlTypeName, int typecode, String targetTypeName) {
   if (!stac.isEmpty()) {
     ListenerHelper listenerHelper = stac.pop();
     if (listenerHelper.isAttribute()) {
       AttributeFieldHelper attributeFieldHelper = (AttributeFieldHelper) listenerHelper;
       attributeFieldHelper.setSqlTypeName(sqlTypeName);
       String fieldName = attributeFieldHelper.attributeFieldName();
       String attributeName = fieldName.toLowerCase();
       ListenerHelper listenerHelper2 = stac.peek();
       if (listenerHelper2.isObject()) {
         ObjectTypeHelper objectTypeHelper = (ObjectTypeHelper) listenerHelper2;
         XMLDescriptor xdesc = descriptorMap.get(objectTypeHelper.objectTypename());
         DatabaseMapping dm = xdesc.getMappingForAttributeName(attributeName);
         if (dm == null) {
           XMLDirectMapping fieldMapping = new XMLDirectMapping();
           fieldMapping.setAttributeName(attributeName);
           XMLField xField = new XMLField(attributeName + "/text()");
           xField.setRequired(true);
           QName qnameFromDatabaseType = qnameFromDatabaseType(listenerHelper);
           xField.setSchemaType(qnameFromDatabaseType);
           // special case to avoid Calendar problems
           if (qnameFromDatabaseType == DATE_QNAME) {
             fieldMapping.setAttributeClassification(java.sql.Date.class);
             xField.addXMLConversion(DATE_QNAME, java.sql.Date.class);
             xField.addJavaConversion(java.sql.Date.class, DATE_QNAME);
             xdesc.getNamespaceResolver().put(SCHEMA_PREFIX, W3C_XML_SCHEMA_NS_URI);
           } else {
             Class attributeClass =
                 (Class) XMLConversionManager.getDefaultXMLTypes().get(qnameFromDatabaseType);
             if (attributeClass == null) {
               attributeClass = Object_Class;
             }
             fieldMapping.setAttributeClassification(attributeClass);
           }
           fieldMapping.setField(xField);
           AbstractNullPolicy nullPolicy = fieldMapping.getNullPolicy();
           nullPolicy.setNullRepresentedByEmptyNode(false);
           nullPolicy.setMarshalNullRepresentation(XSI_NIL);
           nullPolicy.setNullRepresentedByXsiNil(true);
           fieldMapping.setNullPolicy(nullPolicy);
           xdesc
               .getNamespaceResolver()
               .put(
                   SCHEMA_INSTANCE_PREFIX,
                   W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
           xdesc.addMapping(fieldMapping);
         }
         // last attribute, pop ObjectTypeHelper off stack
         int numAttributes = objectTypeHelper.decrNumAttributes();
         if (numAttributes == 0) {
           stac.pop();
         }
       } else if (listenerHelper2.isArray()) {
         SqlArrayTypeHelper sqlArrayTypeHelper = (SqlArrayTypeHelper) listenerHelper2;
         XMLDescriptor xdesc = descriptorMap.get(sqlArrayTypeHelper.arrayTypename());
         DatabaseMapping dm = xdesc.getMappingForAttributeName(attributeName);
         if (dm == null) {
           XMLCompositeDirectCollectionMapping dirCollectMapping =
               new XMLCompositeDirectCollectionMapping();
           SqltypeHelper componentType = new SqltypeHelper(sqlTypeName);
           dirCollectMapping.setAttributeElementClass(
               attributeClassFromDatabaseType((DefaultListenerHelper) componentType));
           dirCollectMapping.setAttributeName(attributeName);
           dirCollectMapping.setUsesSingleNode(true);
           dirCollectMapping.setXPath(attributeName + "/text()");
           XMLField xField = (XMLField) dirCollectMapping.getField();
           xField.setRequired(true);
           xField.setSchemaType(qnameFromDatabaseType(componentType));
           dirCollectMapping.useCollectionClassName("java.util.ArrayList");
           AbstractNullPolicy nullPolicy = dirCollectMapping.getNullPolicy();
           nullPolicy.setNullRepresentedByEmptyNode(false);
           nullPolicy.setMarshalNullRepresentation(XSI_NIL);
           nullPolicy.setNullRepresentedByXsiNil(true);
           dirCollectMapping.setNullPolicy(nullPolicy);
           xdesc
               .getNamespaceResolver()
               .put(
                   SCHEMA_INSTANCE_PREFIX,
                   W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
           xdesc.addMapping(dirCollectMapping);
         }
       }
     } else if (listenerHelper.isArray()) {
       SqlArrayTypeHelper sqlArrayTypeHelper2 = (SqlArrayTypeHelper) listenerHelper;
       XMLDescriptor xdesc = descriptorMap.get(sqlArrayTypeHelper2.arrayTypename());
       DatabaseMapping dm = xdesc.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME);
       if (dm == null) {
         XMLCompositeDirectCollectionMapping itemsMapping =
             new XMLCompositeDirectCollectionMapping();
         SqltypeHelper componentType = new SqltypeHelper(sqlTypeName);
         itemsMapping.setAttributeElementClass(
             attributeClassFromDatabaseType((DefaultListenerHelper) componentType));
         itemsMapping.setAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME);
         itemsMapping.setUsesSingleNode(true);
         itemsMapping.setXPath(ITEM_MAPPING_NAME + "/text()");
         XMLField xField = (XMLField) itemsMapping.getField();
         xField.setRequired(true);
         xField.setSchemaType(qnameFromDatabaseType(componentType));
         itemsMapping.useCollectionClassName("java.util.ArrayList");
         AbstractNullPolicy nullPolicy = itemsMapping.getNullPolicy();
         nullPolicy.setNullRepresentedByEmptyNode(false);
         nullPolicy.setMarshalNullRepresentation(XSI_NIL);
         nullPolicy.setNullRepresentedByXsiNil(true);
         itemsMapping.setNullPolicy(nullPolicy);
         xdesc
             .getNamespaceResolver()
             .put(
                 SCHEMA_INSTANCE_PREFIX,
                 W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
         xdesc.addMapping(itemsMapping);
       }
       ListenerHelper listenerHelper2 = stac.peek();
       if (listenerHelper2.isAttribute()) {
         // type built above used in field definition of object further up stack
         stac.pop();
         AttributeFieldHelper fieldHelper = (AttributeFieldHelper) listenerHelper2;
         ListenerHelper listenerHelper3 = stac.peek();
         if (listenerHelper3.isObject()) {
           ObjectTypeHelper objectTypeHelper = (ObjectTypeHelper) listenerHelper3;
           XMLDescriptor xdesc2 = descriptorMap.get(objectTypeHelper.objectTypename());
           String fieldName = fieldHelper.attributeFieldName();
           DatabaseMapping dm2 = xdesc2.getMappingForAttributeName(fieldName.toLowerCase());
           if (dm2 == null) {
             XMLCompositeDirectCollectionMapping fieldMapping =
                 new XMLCompositeDirectCollectionMapping();
             SqltypeHelper componentType = new SqltypeHelper(sqlTypeName);
             fieldMapping.setAttributeElementClass(
                 attributeClassFromDatabaseType((DefaultListenerHelper) componentType));
             fieldMapping.setAttributeName(fieldName.toLowerCase());
             XMLField field =
                 new XMLField(fieldName.toLowerCase() + "/" + ITEM_MAPPING_NAME + "/text()");
             field.setRequired(true);
             fieldMapping.setField(field);
             field.setSchemaType(qnameFromDatabaseType(componentType));
             fieldMapping.useCollectionClassName("java.util.ArrayList");
             AbstractNullPolicy nullPolicy = fieldMapping.getNullPolicy();
             nullPolicy.setNullRepresentedByEmptyNode(false);
             nullPolicy.setMarshalNullRepresentation(XSI_NIL);
             nullPolicy.setNullRepresentedByXsiNil(true);
             fieldMapping.setNullPolicy(nullPolicy);
             xdesc2
                 .getNamespaceResolver()
                 .put(
                     SCHEMA_INSTANCE_PREFIX,
                     W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
             xdesc2.addMapping(fieldMapping);
           }
           // last attribute, pop ObjectTypeHelper off stack
           int numAttributes = objectTypeHelper.decrNumAttributes();
           if (numAttributes == 0) {
             stac.pop();
           }
         }
       }
     }
   }
 }