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);
}
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);
}
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);
}
}
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);
}
}
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();
}
}
Aggregations