Program: 65053
Project: 65053
Buggy source:
/** 
 * Build a org.eclipse.persistence.internal.helper.DatabaseType  instance  from an org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType instance.  In the the case of PLSQL Packages, the catalog (package) name can be passed in as well.
 */
@SuppressWarnings("String_Node_Str") protected org.eclipse.persistence.internal.helper.DatabaseType buildDatabaseTypeFromMetadataType(DatabaseType dType,String catalog){
  if (dType.isPLSQLCursorType()) {
    if (dType.isArgumentType()) {
      dType=((ArgumentType)dType).getEnclosedType();
    }
    PLSQLCursorType pType=(PLSQLCursorType)dType;
    String typeName=pType.getCursorName();
    if (catalog != null) {
      typeName=(catalog + DOT).concat(typeName);
    }
    return new PLSQLCursor(typeName);
  }
  if (dType.isArgumentType()) {
    dType=((ArgumentType)dType).getEnclosedType();
  }
 else   if (dType.isTYPEType()) {
    dType=((TYPEType)dType).getEnclosedType();
  }
  if (dType.isComposite()) {
    String typeName=dType.getTypeName();
    String compatibleType=typeName.contains(PERCENT) ? typeName.replace(PERCENT,UNDERSCORE) : typeName;
    String javaTypeName=(dType.getTypeName()).toLowerCase();
    if (dType.isPLSQLType()) {
      if (catalog != null && !typeName.contains(ROWTYPE_STR)) {
        typeName=(catalog + "String_Node_Str").concat(typeName);
        compatibleType=(catalog + "String_Node_Str").concat(compatibleType);
        javaTypeName=(catalog.toLowerCase() + "String_Node_Str").concat(javaTypeName);
      }
      if (dType.isPLSQLRecordType()) {
        PLSQLrecord plsqlRec=new PLSQLrecord();
        plsqlRec.setTypeName(typeName);
        plsqlRec.setCompatibleType(compatibleType);
        plsqlRec.setJavaTypeName(javaTypeName);
        for (        FieldType fld : ((PLSQLRecordType)dType).getFields()) {
          if (fld.getEnclosedType().isPrecisionType()) {
            PrecisionType precisionType=(PrecisionType)fld.getEnclosedType();
            plsqlRec.addField(fld.getFieldName(),buildDatabaseTypeFromMetadataType(precisionType),(int)precisionType.getPrecision(),(int)precisionType.getScale());
          }
 else           if (fld.getEnclosedType().isSizedType()) {
            SizedType sizedType=(SizedType)fld.getEnclosedType();
            plsqlRec.addField(fld.getFieldName(),buildDatabaseTypeFromMetadataType(sizedType),(int)sizedType.getSize());
          }
 else {
            plsqlRec.addField(fld.getFieldName(),buildDatabaseTypeFromMetadataType(fld.getEnclosedType(),catalog));
          }
        }
        return plsqlRec;
      }
      PLSQLCollection plsqlCollection=new PLSQLCollection();
      plsqlCollection.setTypeName(typeName);
      plsqlCollection.setCompatibleType(compatibleType);
      plsqlCollection.setJavaTypeName(javaTypeName + COLLECTION_WRAPPER_SUFFIX);
      plsqlCollection.setNestedType(buildDatabaseTypeFromMetadataType(((PLSQLCollectionType)dType).getEnclosedType(),catalog));
      return plsqlCollection;
    }
    if (dType.isVArrayType()) {
      OracleArrayType varray=new OracleArrayType();
      varray.setTypeName(typeName);
      varray.setCompatibleType(compatibleType);
      varray.setJavaTypeName(getGeneratedWrapperClassName(javaTypeName,dbwsBuilder.getProjectName()));
      varray.setNestedType(buildDatabaseTypeFromMetadataType(((VArrayType)dType).getEnclosedType(),null));
      return varray;
    }
    if (dType.isObjectType()) {
      OracleObjectType objType=new OracleObjectType();
      objType.setTypeName(typeName);
      objType.setCompatibleType(compatibleType);
      objType.setJavaTypeName(getGeneratedJavaClassName(javaTypeName,dbwsBuilder.getProjectName()));
      Map<String,org.eclipse.persistence.internal.helper.DatabaseType> fields=objType.getFields();
      ObjectType oType=(ObjectType)dType;
      for (      FieldType field : oType.getFields()) {
        fields.put(field.getFieldName(),buildDatabaseTypeFromMetadataType(field.getEnclosedType()));
      }
      return objType;
    }
    if (dType.isObjectTableType()) {
      OracleArrayType tableType=new OracleArrayType();
      tableType.setTypeName(typeName);
      tableType.setCompatibleType(compatibleType);
      tableType.setJavaTypeName(getGeneratedWrapperClassName(javaTypeName,dbwsBuilder.getProjectName()));
      org.eclipse.persistence.internal.helper.DatabaseType nestedType=buildDatabaseTypeFromMetadataType(((ObjectTableType)dType).getEnclosedType(),null);
      Class wrapper=getWrapperClass(nestedType);
      if (wrapper != null) {
        ((ComplexDatabaseType)nestedType).setJavaType(wrapper);
      }
      tableType.setNestedType(nestedType);
      return tableType;
    }
    return null;
  }
 else   if (dType.isScalar()) {
    org.eclipse.persistence.internal.helper.DatabaseType theType=OraclePLSQLTypes.getDatabaseTypeForCode(((ScalarDatabaseType)dType).getTypeName());
    if (theType != null) {
      return theType;
    }
  }
  return JDBCTypes.getDatabaseTypeForCode(org.eclipse.persistence.tools.dbws.Util.getJDBCTypeFromTypeName(dType.getTypeName()));
}

Fixed version (ground truth):
/** 
 * Build a org.eclipse.persistence.internal.helper.DatabaseType  instance  from an org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType instance.  In the the case of PLSQL Packages, the catalog (package) name can be passed in as well.
 */
@SuppressWarnings("String_Node_Str") protected org.eclipse.persistence.internal.helper.DatabaseType buildDatabaseTypeFromMetadataType(DatabaseType dType,String catalog){
  if (dType.isPLSQLCursorType()) {
    if (dType.isArgumentType()) {
      dType=((ArgumentType)dType).getEnclosedType();
    }
    PLSQLCursorType pType=(PLSQLCursorType)dType;
    String typeName=pType.getCursorName();
    if (catalog != null) {
      typeName=(catalog + DOT).concat(typeName);
    }
    return new PLSQLCursor(typeName);
  }
  if (dType.isArgumentType()) {
    dType=((ArgumentType)dType).getEnclosedType();
  }
 else   if (dType.isTYPEType()) {
    dType=((TYPEType)dType).getEnclosedType();
  }
  if (dType.isComposite()) {
    String typeName=dType.getTypeName();
    String compatibleType=typeName.contains(PERCENT) ? typeName.replace(PERCENT,UNDERSCORE) : typeName;
    String javaTypeName=compatibleType.toLowerCase();
    if (dType.isPLSQLType()) {
      if (catalog != null && !typeName.contains(ROWTYPE_STR)) {
        typeName=(catalog + "String_Node_Str").concat(typeName);
        compatibleType=(catalog + "String_Node_Str").concat(compatibleType);
        javaTypeName=(catalog.toLowerCase() + "String_Node_Str").concat(javaTypeName);
      }
      if (dType.isPLSQLRecordType()) {
        PLSQLrecord plsqlRec=new PLSQLrecord();
        plsqlRec.setTypeName(typeName);
        plsqlRec.setCompatibleType(compatibleType);
        plsqlRec.setJavaTypeName(javaTypeName);
        for (        FieldType fld : ((PLSQLRecordType)dType).getFields()) {
          if (fld.getEnclosedType().isPrecisionType()) {
            PrecisionType precisionType=(PrecisionType)fld.getEnclosedType();
            plsqlRec.addField(fld.getFieldName(),buildDatabaseTypeFromMetadataType(precisionType),(int)precisionType.getPrecision(),(int)precisionType.getScale());
          }
 else           if (fld.getEnclosedType().isSizedType()) {
            SizedType sizedType=(SizedType)fld.getEnclosedType();
            plsqlRec.addField(fld.getFieldName(),buildDatabaseTypeFromMetadataType(sizedType),(int)sizedType.getSize());
          }
 else {
            plsqlRec.addField(fld.getFieldName(),buildDatabaseTypeFromMetadataType(fld.getEnclosedType(),catalog));
          }
        }
        return plsqlRec;
      }
      PLSQLCollection plsqlCollection=new PLSQLCollection();
      plsqlCollection.setTypeName(typeName);
      plsqlCollection.setCompatibleType(compatibleType);
      plsqlCollection.setJavaTypeName(javaTypeName + COLLECTION_WRAPPER_SUFFIX);
      plsqlCollection.setNestedType(buildDatabaseTypeFromMetadataType(((PLSQLCollectionType)dType).getEnclosedType(),catalog));
      return plsqlCollection;
    }
    if (dType.isVArrayType()) {
      OracleArrayType varray=new OracleArrayType();
      varray.setTypeName(typeName);
      varray.setCompatibleType(compatibleType);
      varray.setJavaTypeName(getGeneratedWrapperClassName(javaTypeName,dbwsBuilder.getProjectName()));
      varray.setNestedType(buildDatabaseTypeFromMetadataType(((VArrayType)dType).getEnclosedType(),null));
      return varray;
    }
    if (dType.isObjectType()) {
      OracleObjectType objType=new OracleObjectType();
      objType.setTypeName(typeName);
      objType.setCompatibleType(compatibleType);
      objType.setJavaTypeName(getGeneratedJavaClassName(javaTypeName,dbwsBuilder.getProjectName()));
      Map<String,org.eclipse.persistence.internal.helper.DatabaseType> fields=objType.getFields();
      ObjectType oType=(ObjectType)dType;
      for (      FieldType field : oType.getFields()) {
        fields.put(field.getFieldName(),buildDatabaseTypeFromMetadataType(field.getEnclosedType()));
      }
      return objType;
    }
    if (dType.isObjectTableType()) {
      OracleArrayType tableType=new OracleArrayType();
      tableType.setTypeName(typeName);
      tableType.setCompatibleType(compatibleType);
      tableType.setJavaTypeName(getGeneratedWrapperClassName(javaTypeName,dbwsBuilder.getProjectName()));
      org.eclipse.persistence.internal.helper.DatabaseType nestedType=buildDatabaseTypeFromMetadataType(((ObjectTableType)dType).getEnclosedType(),null);
      Class wrapper=getWrapperClass(nestedType);
      if (wrapper != null) {
        ((ComplexDatabaseType)nestedType).setJavaType(wrapper);
      }
      tableType.setNestedType(nestedType);
      return tableType;
    }
    return null;
  }
 else   if (dType.isScalar()) {
    org.eclipse.persistence.internal.helper.DatabaseType theType=OraclePLSQLTypes.getDatabaseTypeForCode(((ScalarDatabaseType)dType).getTypeName());
    if (theType != null) {
      return theType;
    }
  }
  return JDBCTypes.getDatabaseTypeForCode(org.eclipse.persistence.tools.dbws.Util.getJDBCTypeFromTypeName(dType.getTypeName()));
}