Map<ActualTableName, List<IntrospectedColumn>> columns = getColumns(tc); removeIgnoredColumns(tc, columns); calculateExtraColumnInformation(tc, columns); applyColumnOverrides(tc, columns); calculateIdentityColumns(tc, columns); List<IntrospectedTable> introspectedTables = calculateIntrospectedTables( tc, columns); reportIntrospectionWarnings(introspectedTable, tc, introspectedTable.getFullyQualifiedTable());
.getIntrospectedTableName()); } catch (SQLException e) { closeResultSet(rs); warnings.add(getString("Warning.15")); //$NON-NLS-1$ return; closeResultSet(rs);
table.getIntrospectedTableName(), null); } catch (SQLException e) { closeResultSet(rs); closeResultSet(rs2); warnings.add(getString("Warning.15")); //$NON-NLS-1$ return; rs3 = s.executeQuery(this.getTableRemark(table.getIntrospectedTableName())); while (rs3.next()) { tableComment = rs3.getString("COMMENT"); closeResultSet(rs); closeResultSet(rs2); closeResultSet(rs3);
connection = getConnection(); DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector( this, connection.getMetaData(), javaTypeResolver, warnings); .introspectTables(tc);
private void calculateIdentityColumns(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) { GeneratedKey gk = tc.getGeneratedKey(); if (gk == null) { // no generated key, then no identity or sequence columns return; } for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) { for (IntrospectedColumn introspectedColumn : entry.getValue()) { if (isMatchedColumn(introspectedColumn, gk)) { if (gk.isIdentity() || gk.isJdbcStandard()) { introspectedColumn.setIdentity(true); introspectedColumn.setSequenceColumn(false); } else { introspectedColumn.setIdentity(false); introspectedColumn.setSequenceColumn(true); } } } } }
private List<IntrospectedTable> calculateIntrospectedTables(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) { boolean delimitIdentifiers = tc.isDelimitIdentifiers() || stringContainsSpace(tc.getCatalog()) || stringContainsSpace(tc.getSchema()) || stringContainsSpace(tc.getTableName()); List<IntrospectedTable> answer = new ArrayList<IntrospectedTable>(); for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) { ActualTableName atn = entry.getKey(); // we only use the returned catalog and schema if something was // actually // specified on the table configuration. If something was returned // from the DB for these fields, but nothing was specified on the // table // configuration, then some sort of DB default is being returned // and we don't want that in our SQL FullyQualifiedTable table = new FullyQualifiedTable(stringHasValue(tc.getCatalog()) ? atn.getCatalog() : null, stringHasValue(tc.getSchema()) ? atn.getSchema() : null, atn.getTableName(), tc.getDomainObjectName(), tc.getAlias(), isTrue(tc.getProperty(PropertyRegistry.TABLE_IGNORE_QUALIFIERS_AT_RUNTIME)), tc.getProperty(PropertyRegistry.TABLE_RUNTIME_CATALOG), tc.getProperty(PropertyRegistry.TABLE_RUNTIME_SCHEMA), tc.getProperty(PropertyRegistry.TABLE_RUNTIME_TABLE_NAME), delimitIdentifiers, context); IntrospectedTable introspectedTable = ObjectFactory.createIntrospectedTable(tc, table, context); for (IntrospectedColumn introspectedColumn : entry.getValue()) { introspectedTable.addColumn(introspectedColumn); } calculatePrimaryKey(table, introspectedTable); answer.add(introspectedTable); } return answer; }
ResultSet rs3 = s.executeQuery(this.getClumnRemark(tc.getTableName(),rs.getString("COLUMN_NAME"))); while (rs3.next()) { remarks = rs3.getString("VALUE"); closeResultSet(rs3); closeResultSet(rs);
calculatePrimaryKey(table, introspectedTable); enhanceIntrospectedTable(introspectedTable);
connection = getConnection(); DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector( this, connection.getMetaData(), javaTypeResolver, warnings); .introspectTables(tc);
private void calculateIdentityColumns(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) { GeneratedKey gk = tc.getGeneratedKey(); if (gk == null) { // no generated key, then no identity or sequence columns return; } for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns .entrySet()) { for (IntrospectedColumn introspectedColumn : entry.getValue()) { if (isMatchedColumn(introspectedColumn, gk)) { if (gk.isIdentity() || gk.isJdbcStandard()) { introspectedColumn.setIdentity(true); introspectedColumn.setSequenceColumn(false); } else { introspectedColumn.setIdentity(false); introspectedColumn.setSequenceColumn(true); } } } } }
calculatePrimaryKey(table, introspectedTable);
Map<ActualTableName, List<IntrospectedColumn>> columns = getColumns(tc); removeIgnoredColumns(tc, columns); calculateExtraColumnInformation(tc, columns); applyColumnOverrides(tc, columns); calculateIdentityColumns(tc, columns); List<IntrospectedTable> introspectedTables = calculateIntrospectedTables(tc, columns); reportIntrospectionWarnings(introspectedTable, tc, introspectedTable.getFullyQualifiedTable());
connection = getConnection(); DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector(this, connection.getMetaData(), javaTypeResolver, warnings); List<IntrospectedTable> tables = databaseIntrospector.introspectTables(tc);
private void calculatePrimaryKey(FullyQualifiedTable table, IntrospectedTable introspectedTable) { ResultSet rs = null; try { rs = databaseMetaData.getPrimaryKeys( table.getIntrospectedCatalog(), table .getIntrospectedSchema(), table .getIntrospectedTableName()); } catch (SQLException e) { closeResultSet(rs); warnings.add(getString("Warning.15")); //$NON-NLS-1$ return; } try { // keep primary columns in key sequence order Map<Short, String> keyColumns = new TreeMap<Short, String>(); while (rs.next()) { String columnName = rs.getString("COLUMN_NAME"); //$NON-NLS-1$ short keySeq = rs.getShort("KEY_SEQ"); //$NON-NLS-1$ keyColumns.put(keySeq, columnName); } for (String columnName : keyColumns.values()) { introspectedTable.addPrimaryKeyColumn(columnName); } } catch (SQLException e) { // ignore the primary key if there's any error } finally { closeResultSet(rs); } }
private void calculateIdentityColumns(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) { GeneratedKey gk = tc.getGeneratedKey(); if (gk == null) { // no generated key, then no identity or sequence columns return; } for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns .entrySet()) { for (IntrospectedColumn introspectedColumn : entry.getValue()) { if (isMatchedColumn(introspectedColumn, gk)) { if (gk.isIdentity() || gk.isJdbcStandard()) { introspectedColumn.setIdentity(true); introspectedColumn.setSequenceColumn(false); } else { introspectedColumn.setIdentity(false); introspectedColumn.setSequenceColumn(true); } } } } }
calculatePrimaryKey(table, introspectedTable);
Map<ActualTableName, List<IntrospectedColumn>> columns = getColumns(tc); removeIgnoredColumns(tc, columns); calculateExtraColumnInformation(tc, columns); applyColumnOverrides(tc, columns); calculateIdentityColumns(tc, columns); List<IntrospectedTable> introspectedTables = calculateIntrospectedTables( tc, columns); reportIntrospectionWarnings(introspectedTable, tc, introspectedTable.getFullyQualifiedTable());
connection = getConnection(); DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector(this, connection.getMetaData(), javaTypeResolver, warnings); List<IntrospectedTable> tables = databaseIntrospector.introspectTables(tc);
.getIntrospectedTableName()); } catch (SQLException e) { closeResultSet(rs); warnings.add(getString("Warning.15")); //$NON-NLS-1$ return; closeResultSet(rs);
private void calculateIdentityColumns(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) { GeneratedKey gk = tc.getGeneratedKey(); if (gk == null) { // no generated key, then no identity or sequence columns return; } for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns .entrySet()) { for (IntrospectedColumn introspectedColumn : entry.getValue()) { if (isMatchedColumn(introspectedColumn, gk)) { if (gk.isIdentity() || gk.isJdbcStandard()) { introspectedColumn.setIdentity(true); introspectedColumn.setSequenceColumn(false); } else { introspectedColumn.setIdentity(false); introspectedColumn.setSequenceColumn(true); } } } } }