Search in sources :

Example 11 with StatementConfig

use of org.dbflute.jdbc.StatementConfig in project dbflute-core by dbflute.

the class TnStatementFactoryImplTest method test_getActualStatementConfig_defaultMerge_defaultAll.

// ===================================================================================
//          DefaultMerge
// ============
public void test_getActualStatementConfig_defaultMerge_defaultAll() throws Exception {
    // ## Arrange ##
    TnStatementFactoryImpl impl = new TnStatementFactoryImpl();
    {
        StatementConfig defaultConfig = new StatementConfig();
        defaultConfig.queryTimeout(10).fetchSize(20).maxRows(30);
        impl.setDefaultStatementConfig(defaultConfig);
    }
    StatementConfig config = new StatementConfig();
    config.fetchSize(2);
    // ## Act ##
    StatementConfig actual = impl.getActualStatementConfig(config);
    // ## Assert ##
    assertNotNull(actual);
    assertEquals(10, actual.getQueryTimeout());
    assertEquals(2, actual.getFetchSize());
    assertEquals(30, actual.getMaxRows());
}
Also used : StatementConfig(org.dbflute.jdbc.StatementConfig)

Example 12 with StatementConfig

use of org.dbflute.jdbc.StatementConfig in project dbflute-core by dbflute.

the class TnStatementFactoryImplTest method test_getResultSetType_request.

public void test_getResultSetType_request() throws Exception {
    // ## Arrange ##
    TnStatementFactoryImpl impl = new TnStatementFactoryImpl();
    StatementConfig config = new StatementConfig();
    config.typeScrollInsensitive();
    // ## Act ##
    int resultSetType = impl.getResultSetType(config);
    // ## Assert ##
    assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, resultSetType);
}
Also used : StatementConfig(org.dbflute.jdbc.StatementConfig)

Example 13 with StatementConfig

use of org.dbflute.jdbc.StatementConfig in project dbflute-core by dbflute.

the class TnStatementFactoryImplTest method test_getActualStatementConfig_cursorSelectFetchSize_cursor_merged.

public void test_getActualStatementConfig_cursorSelectFetchSize_cursor_merged() throws Exception {
    // ## Arrange ##
    TnStatementFactoryImpl impl = new TnStatementFactoryImpl() {

        @Override
        protected boolean isSelectCursorFetchSizeCommand(BehaviorCommand<?> command) {
            return true;
        }
    };
    {
        StatementConfig defaultConfig = new StatementConfig();
        defaultConfig.queryTimeout(10).fetchSize(20).maxRows(30);
        impl.setDefaultStatementConfig(defaultConfig);
    }
    impl.setCursorSelectFetchSize(200);
    StatementConfig config = new StatementConfig();
    config.queryTimeout(1);
    // ## Act ##
    StatementConfig actual = impl.getActualStatementConfig(config);
    // ## Assert ##
    assertNotNull(actual);
    assertEquals(1, actual.getQueryTimeout());
    assertEquals(200, actual.getFetchSize());
    assertEquals(30, actual.getMaxRows());
}
Also used : StatementConfig(org.dbflute.jdbc.StatementConfig) BehaviorCommand(org.dbflute.bhv.core.BehaviorCommand)

Example 14 with StatementConfig

use of org.dbflute.jdbc.StatementConfig in project dbflute-core by dbflute.

the class TnStatementFactoryImpl method findStatementConfigOnThread.

// -----------------------------------------------------
// StatementConfig
// ---------------
protected StatementConfig findStatementConfigOnThread() {
    final StatementConfig config;
    if (ConditionBeanContext.isExistConditionBeanOnThread()) {
        final ConditionBean cb = ConditionBeanContext.getConditionBeanOnThread();
        config = cb.getStatementConfig();
    } else if (OutsideSqlContext.isExistOutsideSqlContextOnThread()) {
        final OutsideSqlContext context = OutsideSqlContext.getOutsideSqlContextOnThread();
        config = context.getStatementConfig();
    } else {
        // update or no exist
        config = InternalMapContext.getUpdateStatementConfig();
    }
    return config;
}
Also used : OutsideSqlContext(org.dbflute.outsidesql.OutsideSqlContext) ConditionBean(org.dbflute.cbean.ConditionBean) StatementConfig(org.dbflute.jdbc.StatementConfig)

Example 15 with StatementConfig

use of org.dbflute.jdbc.StatementConfig in project dbflute-core by dbflute.

the class TnStatementFactoryImpl method getActualStatementConfig.

protected StatementConfig getActualStatementConfig(StatementConfig config) {
    final StatementConfig defaultConfig = getActualDefaultConfig(config);
    final Integer queryTimeout = getActualQueryTimeout(config, defaultConfig);
    final Integer fetchSize = getActualFetchSize(config, defaultConfig);
    final Integer maxRows = getActualMaxRows(config, defaultConfig);
    if (queryTimeout == null && fetchSize == null && maxRows == null) {
        return null;
    }
    final StatementConfig actualConfig = new StatementConfig();
    actualConfig.queryTimeout(queryTimeout).fetchSize(fetchSize).maxRows(maxRows);
    return actualConfig;
}
Also used : StatementConfig(org.dbflute.jdbc.StatementConfig)

Aggregations

StatementConfig (org.dbflute.jdbc.StatementConfig)29 BehaviorCommand (org.dbflute.bhv.core.BehaviorCommand)6 CallableStatement (java.sql.CallableStatement)1 PreparedStatement (java.sql.PreparedStatement)1 ConditionBean (org.dbflute.cbean.ConditionBean)1 OutsideSqlContext (org.dbflute.outsidesql.OutsideSqlContext)1