ObjectRelationalDataTypeDescriptor ordt =
descriptorMap.get(sqlArrayTypeHelper.arrayTypename());
DatabaseMapping dm = ordt.getMappingForAttributeName(attributeName);
if (dm == null) {
ordt.addFieldOrdering(fieldName);
ArrayMapping arrayMapping = new ArrayMapping();
arrayMapping.setFieldName(fieldName);
arrayMapping.setAttributeName(attributeName);
arrayMapping.useCollectionClass(ArrayList.class);
arrayMapping.setStructureName(sqlArrayTypeHelper.arrayTypename().toUpperCase());
DatabaseField nestedField = new DatabaseField("");
nestedField.setSqlType(typecode);
nestedField.setColumnDefinition(sqlTypeName);
ObjectRelationalDatabaseField field =
(ObjectRelationalDatabaseField)arrayMapping.getField();
field.setNestedTypeField(nestedField);
ordt.addMapping(arrayMapping);
}
}
}
else if (listenerHelper.isArray()) {
SqlArrayTypeHelper sqlArrayTypeHelper = (SqlArrayTypeHelper)listenerHelper;
ObjectRelationalDataTypeDescriptor ordt =
descriptorMap.get(sqlArrayTypeHelper.arrayTypename());
DatabaseMapping dm = ordt.getMappingForAttributeName(ITEMS_ATTRIBUTE_NAME);
if (dm == null) {
ArrayMapping arrayMapping = new ArrayMapping();
arrayMapping.setFieldName(ITEMS_ATTRIBUTE_NAME);
arrayMapping.setAttributeName(ITEMS_ATTRIBUTE_NAME);
arrayMapping.useCollectionClass(ArrayList.class);
arrayMapping.setStructureName(sqlArrayTypeHelper.arrayTypename().toUpperCase());
DatabaseField nestedField = new DatabaseField("");
nestedField.setSqlType(typecode);
nestedField.setColumnDefinition(sqlTypeName);
ObjectRelationalDatabaseField field =
(ObjectRelationalDatabaseField)arrayMapping.getField();
field.setNestedTypeField(nestedField);
ordt.addMapping(arrayMapping);
}
ListenerHelper listenerHelper3 = stac.peek();
ListenerHelper listenerHelper4 = null;
if (listenerHelper3.isArray()) {
/*
* table of table scenario:
CREATE TYPE SOMEPACKAGE_TBL2 AS TABLE OF NUMBER;
CREATE TYPE SOMEPACKAGE_TBL4 AS TABLE OF SOMEPACKAGE_TBL2;
*/
SqlArrayTypeHelper sqlArrayTypeHelper2 = (SqlArrayTypeHelper)listenerHelper3;
stac.pop();
ObjectRelationalDataTypeDescriptor ordt3 =
descriptorMap.get(sqlArrayTypeHelper2.arrayTypename());
DatabaseMapping dm3 = ordt3.getMappingForAttributeName(ITEMS_ATTRIBUTE_NAME);
if (dm3 == null) {
ObjectArrayMapping objArrayMapping = new ObjectArrayMapping();
objArrayMapping.setAttributeName(ITEMS_ATTRIBUTE_NAME);
objArrayMapping.setFieldName(ITEMS_ATTRIBUTE_NAME);
objArrayMapping.setStructureName(sqlArrayTypeHelper2.arrayTypename().toUpperCase());
objArrayMapping.setReferenceClassName(ordt.getJavaClassName());
objArrayMapping.useCollectionClass(ArrayList.class);
ordt3.addMapping(objArrayMapping);
}
// more stack peeking
if (stac.peek().isAttribute()) {
listenerHelper4 = stac.peek();
}
}
else {
listenerHelper4 = listenerHelper3;
}
if (listenerHelper4.isAttribute()) {
// type built above used in field definition of object further up stack
AttributeFieldHelper fieldHelper = (AttributeFieldHelper)listenerHelper4;
stac.pop();
ListenerHelper listenerHelper5 = stac.peek();
if (listenerHelper5.isObject()) {
ObjectTypeHelper objectTypeHelper = (ObjectTypeHelper)listenerHelper5;
ObjectRelationalDataTypeDescriptor ordt2 =
descriptorMap.get(objectTypeHelper.objectTypename());
String fieldName = fieldHelper.attributeFieldName();
DatabaseMapping dm2 =
ordt2.getMappingForAttributeName(fieldName.toLowerCase());
if (dm2 == null) {
ordt2.addFieldOrdering(fieldName);
// simple or complex array?
if (listenerHelper4 == listenerHelper3) {
ArrayMapping arrayMapping2 = new ArrayMapping();
arrayMapping2.setAttributeName(fieldName.toLowerCase());
arrayMapping2.setFieldName(fieldName);
arrayMapping2.setStructureName(sqlArrayTypeHelper.arrayTypename().toUpperCase());
arrayMapping2.useCollectionClass(ArrayList.class);
DatabaseField nestedField = new DatabaseField("");
nestedField.setSqlType(typecode);
nestedField.setColumnDefinition(sqlTypeName);
ObjectRelationalDatabaseField field =
(ObjectRelationalDatabaseField)arrayMapping2.getField();
field.setNestedTypeField(nestedField);
ordt2.addMapping(arrayMapping2);
}
else {
ObjectArrayMapping objArrayMapping2 = new ObjectArrayMapping();