Search in sources :

Example 1 with DfTableMeta

use of org.dbflute.logic.jdbc.metadata.info.DfTableMeta in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method resolveAdditionalSchema.

protected void resolveAdditionalSchema(DatabaseMetaData dbMeta, List<DfTableMeta> tableList) throws SQLException {
    if (_suppressAdditionalSchema) {
        return;
    }
    final List<UnifiedSchema> schemaList = getDatabaseProperties().getAdditionalSchemaList();
    for (UnifiedSchema additionalSchema : schemaList) {
        final List<DfTableMeta> additionalTableList = _tableExtractor.getTableList(dbMeta, additionalSchema);
        helpTableBasicSupplement(additionalTableList, additionalSchema);
        tableList.addAll(additionalTableList);
    }
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta)

Example 2 with DfTableMeta

use of org.dbflute.logic.jdbc.metadata.info.DfTableMeta in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method getTableList.

// ===================================================================================
// Meta Data Handler
// =================
// -----------------------------------------------------
// Table
// -----
/**
 * Get the list of table meta in the current database that are not system tables.
 * @param dbMeta The meta data of a database. (NotNull)
 * @return The list of all the tables in a database. (NotNull)
 * @throws SQLException When it fails to handle the SQL.
 */
public List<DfTableMeta> getTableList(DatabaseMetaData dbMeta) throws SQLException {
    final UnifiedSchema mainSchema = _dataSource.getSchema();
    final List<DfTableMeta> tableList = _tableExtractor.getTableList(dbMeta, mainSchema);
    helpTableBasicSupplement(tableList, mainSchema);
    resolveAdditionalSchema(dbMeta, tableList);
    assertDuplicateTable(tableList);
    // table names from meta data are used so basically it does not need it
    // but it prepares here just in case
    prepareTableCaseTranslation(tableList);
    return tableList;
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta)

Example 3 with DfTableMeta

use of org.dbflute.logic.jdbc.metadata.info.DfTableMeta in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method prepareTableCaseTranslation.

protected void prepareTableCaseTranslation(List<DfTableMeta> tableList) {
    final List<String> tableNameList = new ArrayList<String>();
    for (DfTableMeta meta : tableList) {
        tableNameList.add(meta.getTableDbName());
    }
    _columnExtractor.enableTableCaseTranslation(tableNameList);
    _uniqueKeyExtractor.enableTableCaseTranslation(tableNameList);
    _indexExtractor.enableTableCaseTranslation(tableNameList);
    _foreignKeyExtractor.enableTableCaseTranslation(tableNameList);
}
Also used : ArrayList(java.util.ArrayList) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta)

Example 4 with DfTableMeta

use of org.dbflute.logic.jdbc.metadata.info.DfTableMeta in project dbflute-core by dbflute.

the class DfSynonymExtractorOracle method isForeignTableGenerated.

protected boolean isForeignTableGenerated(UnifiedSchema tableOwner, String foreignTableName) {
    if (_generatedTableMap == null || _generatedTableMap.isEmpty()) {
        // means no check of generation
        return true;
    }
    final DfTableMeta info = _generatedTableMap.get(foreignTableName);
    if (info == null) {
        return false;
    }
    final UnifiedSchema unifiedSchema = info.getUnifiedSchema();
    if (!unifiedSchema.getPureSchema().equals(tableOwner.getPureSchema())) {
        // (tables in same schema are target here)
        return false;
    }
    if (info.isOutOfGenerateTarget()) {
        return false;
    }
    return true;
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta)

Example 5 with DfTableMeta

use of org.dbflute.logic.jdbc.metadata.info.DfTableMeta in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method processTable.

// -----------------------------------------------------
// Table
// -----
protected void processTable(final Connection conn, final DatabaseMetaData metaData, final List<DfTableMeta> tableList) throws SQLException {
    _log.info("");
    _log.info("$ /= = = = = = = = = = = = = = = = = = = = = = = = = =");
    _log.info("$ [Table List]");
    final int runnerCount = getMetaDataCountDownRaceRunnerCount();
    if (runnerCount > 1 && _dataSource.getDataSource() instanceof DfFittingDataSource) {
        countDownRaceProcessTable(tableList, runnerCount, (DfFittingDataSource) _dataSource.getDataSource());
    } else {
        for (DfTableMeta tableMeta : tableList) {
            doProcessTable(conn, metaData, tableMeta);
        }
    }
    for (Element element : _tableElementStagingMap.values()) {
        _databaseNode.appendChild(element);
    }
    _log.info("$ ");
    _log.info("$ [Table Count]");
    _log.info("$ " + _tableElementStagingMap.size());
    _log.info("$ = = = = = = = = = =/");
    _log.info("");
}
Also used : DfFittingDataSource(org.dbflute.helper.jdbc.connection.DfFittingDataSource) Element(org.w3c.dom.Element) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta) Constraint(org.apache.torque.engine.database.model.Constraint)

Aggregations

DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)31 SQLException (java.sql.SQLException)12 Connection (java.sql.Connection)9 DatabaseMetaData (java.sql.DatabaseMetaData)8 Statement (java.sql.Statement)8 ArrayList (java.util.ArrayList)7 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)6 Map (java.util.Map)4 Entry (java.util.Map.Entry)4 SQLFailureException (org.dbflute.exception.SQLFailureException)4 DfPrimaryKeyMeta (org.dbflute.logic.jdbc.metadata.info.DfPrimaryKeyMeta)4 StringKeyMap (org.dbflute.helper.StringKeyMap)3 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 TypeMap (org.apache.torque.engine.database.model.TypeMap)2