private static NodeData getTableConfigXmlNodeData0(String tableSqlName) {
   try {
     File file =
         FileHelper.getFileByClassLoader("generator_config/table/" + tableSqlName + ".xml");
     GLogger.trace("getTableConfigXml() load nodeData by tableSqlName:" + tableSqlName + ".xml");
     return new XMLHelper().parseXML(file);
   } catch (Exception e) { // ignore
     GLogger.trace("not found config xml for table:" + tableSqlName + ", exception:" + e);
     return null;
   }
 }
  private List getTableColumns(
      Table table, List primaryKeys, List indices, Map uniqueIndices, Map uniqueColumns)
      throws SQLException {
    // get the columns
    List columns = new LinkedList();
    ResultSet columnRs = getColumnsResultSet(table);

    while (columnRs.next()) {
      int sqlType = columnRs.getInt("DATA_TYPE");
      String sqlTypeName = columnRs.getString("TYPE_NAME");
      String columnName = columnRs.getString("COLUMN_NAME");
      String columnDefaultValue = columnRs.getString("COLUMN_DEF");

      String remarks = columnRs.getString("REMARKS");
      if (remarks == null && dbHelper.isOracleDataBase()) {
        remarks = getOracleColumnComments(table.getSqlName(), columnName);
      }

      // if columnNoNulls or columnNullableUnknown assume "not nullable"
      boolean isNullable = (DatabaseMetaData.columnNullable == columnRs.getInt("NULLABLE"));
      int size = columnRs.getInt("COLUMN_SIZE");
      int decimalDigits = columnRs.getInt("DECIMAL_DIGITS");

      boolean isPk = primaryKeys.contains(columnName);
      boolean isIndexed = indices.contains(columnName);
      String uniqueIndex = (String) uniqueIndices.get(columnName);
      List columnsInUniqueIndex = null;
      if (uniqueIndex != null) {
        columnsInUniqueIndex = (List) uniqueColumns.get(uniqueIndex);
      }

      boolean isUnique = columnsInUniqueIndex != null && columnsInUniqueIndex.size() == 1;
      if (isUnique) {
        GLogger.trace("unique column:" + columnName);
      }
      Column column =
          new Column(
              table,
              sqlType,
              sqlTypeName,
              columnName,
              size,
              decimalDigits,
              isPk,
              isNullable,
              isIndexed,
              isUnique,
              columnDefaultValue,
              remarks);
      BeanHelper.copyProperties(
          column, TableOverrideValuesProvider.getColumnOverrideValues(table, column));
      columns.add(column);
    }
    columnRs.close();
    return columns;
  }
 private List<String> getTablePrimaryKeys(Table table) throws SQLException {
   // get the primary keys
   List primaryKeys = new LinkedList();
   ResultSet primaryKeyRs = null;
   if (table.getOwnerSynonymName() != null) {
     primaryKeyRs =
         getMetaData()
             .getPrimaryKeys(getCatalog(), table.getOwnerSynonymName(), table.getSqlName());
   } else {
     primaryKeyRs = getMetaData().getPrimaryKeys(getCatalog(), getSchema(), table.getSqlName());
   }
   while (primaryKeyRs.next()) {
     String columnName = primaryKeyRs.getString("COLUMN_NAME");
     GLogger.trace("primary key:" + columnName);
     primaryKeys.add(columnName);
   }
   primaryKeyRs.close();
   return primaryKeys;
 }
  private void retriveTableColumns(Table table) throws SQLException {
    GLogger.trace("-------setColumns(" + table.getSqlName() + ")");

    List primaryKeys = getTablePrimaryKeys(table);
    table.setPrimaryKeyColumns(primaryKeys);

    // get the indices and unique columns
    List indices = new LinkedList();
    // maps index names to a list of columns in the index
    Map uniqueIndices = new HashMap();
    // maps column names to the index name.
    Map uniqueColumns = new HashMap();
    ResultSet indexRs = null;

    try {

      if (table.getOwnerSynonymName() != null) {
        indexRs =
            getMetaData()
                .getIndexInfo(
                    getCatalog(), table.getOwnerSynonymName(), table.getSqlName(), false, true);
      } else {
        indexRs =
            getMetaData().getIndexInfo(getCatalog(), getSchema(), table.getSqlName(), false, true);
      }
      while (indexRs.next()) {
        String columnName = indexRs.getString("COLUMN_NAME");
        if (columnName != null) {
          GLogger.trace("index:" + columnName);
          indices.add(columnName);
        }

        // now look for unique columns
        String indexName = indexRs.getString("INDEX_NAME");
        boolean nonUnique = indexRs.getBoolean("NON_UNIQUE");

        if (!nonUnique && columnName != null && indexName != null) {
          List l = (List) uniqueColumns.get(indexName);
          if (l == null) {
            l = new ArrayList();
            uniqueColumns.put(indexName, l);
          }
          l.add(columnName);
          uniqueIndices.put(columnName, indexName);
          GLogger.trace("unique:" + columnName + " (" + indexName + ")");
        }
      }
    } catch (Throwable t) {
      // Bug #604761 Oracle getIndexInfo() needs major grants
      // http://sourceforge.net/tracker/index.php?func=detail&aid=604761&group_id=36044&atid=415990
    } finally {
      dbHelper.close(indexRs, null);
    }

    List columns = getTableColumns(table, primaryKeys, indices, uniqueIndices, uniqueColumns);

    for (Iterator i = columns.iterator(); i.hasNext(); ) {
      Column column = (Column) i.next();
      table.addColumn(column);
    }

    // In case none of the columns were primary keys, issue a warning.
    if (primaryKeys.size() == 0) {
      GLogger.warn(
          "WARNING: The JDBC driver didn't report any primary key columns in "
              + table.getSqlName());
    }
  }