Search in sources :

Example 1 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfLReverseDataExtractor method processNormalData.

// ===================================================================================
// Normal Data
// ===========
protected DfLReverseDataResult processNormalData(Table table, String sql) {
    final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
    final Map<String, ValueType> valueTypeMap = createColumnValueTypeMap(table.getColumnList());
    final DfJFadStringConverter converter = createStringConverter();
    final Integer limit = _extractingLimit;
    final List<Map<String, String>> resultList = facade.selectStringList(sql, valueTypeMap, converter, limit);
    return new DfLReverseDataResult(resultList);
}
Also used : DfJFadStringConverter(org.dbflute.helper.jdbc.facade.DfJFadStringConverter) ValueType(org.dbflute.jdbc.ValueType) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 2 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfLReverseDataExtractor method processLargeData.

// ===================================================================================
// Large Data
// ==========
protected DfLReverseDataResult processLargeData(Table table, final String sql) {
    final DfJdbcFacade facade = new DfJdbcFacade(_dataSource);
    final Map<String, ValueType> valueTypeMap = createColumnValueTypeMap(table.getColumnList());
    final DfJFadStringConverter converter = createStringConverter();
    final DfJFadCursorCallback callback = facade.selectCursor(sql, valueTypeMap, converter);
    return new DfLReverseDataResult(callback);
}
Also used : DfJFadStringConverter(org.dbflute.helper.jdbc.facade.DfJFadStringConverter) ValueType(org.dbflute.jdbc.ValueType) DfJFadCursorCallback(org.dbflute.helper.jdbc.facade.DfJFadCursorCallback) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 3 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfSchemaInitializerDB2 method dropSequence.

// ===================================================================================
// Drop Sequence
// =============
@Override
protected void dropSequence(Connection conn, List<DfTableMeta> tableMetaInfoList) {
    if (!_unifiedSchema.hasSchema()) {
        return;
    }
    final String schema = _unifiedSchema.getPureSchema();
    final List<String> sequenceNameList = new ArrayList<String>();
    final DfJdbcFacade jdbcFacade = new DfJdbcFacade(conn);
    final String sequenceColumnName = "sequence_name";
    final StringBuilder sb = new StringBuilder();
    sb.append("select SEQNAME as ").append(sequenceColumnName).append(" from SYSCAT.SEQUENCES");
    sb.append(" where SEQSCHEMA = '").append(schema).append("'");
    final String sql = sb.toString();
    final List<String> sequenceColumnList = Arrays.asList(sequenceColumnName);
    final List<Map<String, String>> resultList = jdbcFacade.selectStringList(sql, sequenceColumnList);
    for (Map<String, String> recordMap : resultList) {
        sequenceNameList.add(recordMap.get(sequenceColumnName));
    }
    for (String sequenceName : sequenceNameList) {
        if (isSequenceExcept(sequenceName)) {
            continue;
        }
        final String dropSequenceSql = "drop sequence " + schema + "." + sequenceName;
        logReplaceSql(dropSequenceSql);
        jdbcFacade.execute(dropSequenceSql);
    }
}
Also used : ArrayList(java.util.ArrayList) Map(java.util.Map) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 4 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfSchemaInitializerH2 method dropSequence.

// ===================================================================================
// Drop Sequence
// =============
@Override
protected void dropSequence(Connection conn, List<DfTableMeta> tableMetaInfoList) {
    final String catalog = _unifiedSchema.existsPureCatalog() ? _unifiedSchema.getPureCatalog() : null;
    final String schema = _unifiedSchema.getPureSchema();
    final List<String> sequenceNameList = new ArrayList<String>();
    final DfJdbcFacade jdbcFacade = new DfJdbcFacade(conn);
    final String sequenceColumnName = "sequence_name";
    final StringBuilder sb = new StringBuilder();
    sb.append("select ").append(sequenceColumnName).append(" from information_schema.sequences");
    sb.append(" where ");
    if (Srl.is_NotNull_and_NotTrimmedEmpty(catalog)) {
        sb.append("sequence_catalog = '").append(catalog).append("'").append(" and ");
    }
    sb.append("sequence_schema = '").append(schema).append("'");
    final String sql = sb.toString();
    final List<String> sequenceColumnList = Arrays.asList(sequenceColumnName);
    final List<Map<String, String>> resultList = jdbcFacade.selectStringList(sql, sequenceColumnList);
    for (Map<String, String> recordMap : resultList) {
        sequenceNameList.add(recordMap.get(sequenceColumnName));
    }
    for (String sequenceName : sequenceNameList) {
        if (isSequenceExcept(sequenceName)) {
            continue;
        }
        final String sequenceSqlName = _unifiedSchema.buildSqlName(sequenceName);
        final String dropSequenceSql = "drop sequence " + sequenceSqlName;
        logReplaceSql(dropSequenceSql);
        jdbcFacade.execute(dropSequenceSql);
    }
}
Also used : ArrayList(java.util.ArrayList) Map(java.util.Map) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 5 with DfJdbcFacade

use of org.dbflute.helper.jdbc.facade.DfJdbcFacade in project dbflute-core by dbflute.

the class DfSchemaInitializerPostgreSQL method selectInheritList.

protected List<Map<String, String>> selectInheritList(Connection conn) {
    final StringBuilder sb = new StringBuilder();
    sb.append("select rits.inhrelid, child_cls.relname as child_name");
    sb.append(", rits.inhparent, parent_cls.relname as parent_name, inhseqno");
    sb.append(" from pg_inherits rits");
    sb.append(" left outer join pg_class child_cls on rits.inhrelid = child_cls.oid");
    sb.append(" left outer join pg_class parent_cls on rits.inhparent = parent_cls.oid");
    final String sql = sb.toString();
    final List<String> colList = Arrays.asList("inhrelid", "child_name", "inhparent", "parent_name", "inhseqno");
    final DfJdbcFacade jdbcFacade = new DfJdbcFacade(conn);
    try {
        return jdbcFacade.selectStringList(sql, colList);
    } catch (RuntimeException continued) {
        _log.info("*Failed to select pg_inherits for priority of dropping table: " + continued.getMessage());
        return DfCollectionUtil.emptyList();
    }
}
Also used : DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Aggregations

DfJdbcFacade (org.dbflute.helper.jdbc.facade.DfJdbcFacade)23 Map (java.util.Map)13 ArrayList (java.util.ArrayList)12 StringKeyMap (org.dbflute.helper.StringKeyMap)5 DfJFadStringConverter (org.dbflute.helper.jdbc.facade.DfJFadStringConverter)4 ValueType (org.dbflute.jdbc.ValueType)4 LinkedHashMap (java.util.LinkedHashMap)2 DfJFadCursorCallback (org.dbflute.helper.jdbc.facade.DfJFadCursorCallback)2 SQLException (java.sql.SQLException)1 SQLFailureException (org.dbflute.exception.SQLFailureException)1 DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)1