db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rijk van Haaften (JIRA)" <j...@apache.org>
Subject [jira] Created: (DDLUTILS-227) NullPointerException in ModelBasedResultSetIterator
Date Tue, 30 Sep 2008 11:48:44 GMT
NullPointerException in ModelBasedResultSetIterator

                 Key: DDLUTILS-227
                 URL: https://issues.apache.org/jira/browse/DDLUTILS-227
             Project: DdlUtils
          Issue Type: Bug
          Components: Core (No specific database), Core - HSQLDB
         Environment: HSQLDB
            Reporter: Rijk van Haaften
            Assignee: Thomas Dudziak

The bug is in initFromMetaData(Database)

For subqueries in HSQLDB, tableOfColumn = metaData.getTableName(idx) = "SYSTEM_SUBQUERY",
rather than null or "", so the if-block (see below) is executed.
That table, of course is not in the model, so table = model.findTable... will set table to
That is correct. But unlike the else-block, tableOfColumn is left unchanged.
This causes the tableName to be wrong, which later on sets the _dynaClass to be null: _dynaClass
= model.getDynaClassFor(tableName); // model does not contain a "SYSTEM_SUBQUERY"-table
This finally causes a NullPointerException in the implementation of next():
DynaBean bean  = _dynaClass.newInstance();

The solution is simple: Update the tableOfColumn not only in the else-block, but always (only
the last few lines changed):

            if ((tableOfColumn != null) && (tableOfColumn.length() > 0))
                _log.debug("Table from metadata: " + tableOfColumn);
                // jConnect might return a table name enclosed in quotes
                if (tableOfColumn.startsWith("\"") && tableOfColumn.endsWith("\"")
&& (tableOfColumn.length() > 1))
                    tableOfColumn = tableOfColumn.substring(1, tableOfColumn.length() - 1);
                // the JDBC driver gave us enough meta data info
                table = model.findTable(tableOfColumn, _caseSensitive);
                _log.debug("Try query hints");
                // not enough info in the meta data of the result set, lets try the
                // user-supplied query hints
                table         = (Table)_preparedQueryHints.get(_caseSensitive ? columnName
: columnName.toLowerCase());
            tableOfColumn = (table == null ? null : table.getName()); // Moved out of the

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message