Search in sources :

Example 1 with ParameterHandler

use of org.apache.ibatis.executor.parameter.ParameterHandler in project mybatis-3 by mybatis.

the class DefaultResultSetHandlerTest method shouldRetainColumnNameCase.

/**
   * Contrary to the spec, some drivers require case-sensitive column names when getting result.
   * 
   * @see <a href="http://code.google.com/p/mybatis/issues/detail?id=557">Issue 557</a>
   */
@Test
public void shouldRetainColumnNameCase() throws Exception {
    final MappedStatement ms = getMappedStatement();
    final Executor executor = null;
    final ParameterHandler parameterHandler = null;
    final ResultHandler resultHandler = null;
    final BoundSql boundSql = null;
    final RowBounds rowBounds = new RowBounds(0, 100);
    final DefaultResultSetHandler fastResultSetHandler = new DefaultResultSetHandler(executor, ms, parameterHandler, resultHandler, boundSql, rowBounds);
    when(stmt.getResultSet()).thenReturn(rs);
    when(rs.getMetaData()).thenReturn(rsmd);
    when(rs.getType()).thenReturn(ResultSet.TYPE_FORWARD_ONLY);
    when(rs.next()).thenReturn(true).thenReturn(false);
    when(rs.getInt("CoLuMn1")).thenReturn(100);
    when(rs.wasNull()).thenReturn(false);
    when(rsmd.getColumnCount()).thenReturn(1);
    when(rsmd.getColumnLabel(1)).thenReturn("CoLuMn1");
    when(rsmd.getColumnType(1)).thenReturn(Types.INTEGER);
    when(rsmd.getColumnClassName(1)).thenReturn(Integer.class.getCanonicalName());
    when(stmt.getConnection()).thenReturn(conn);
    when(conn.getMetaData()).thenReturn(dbmd);
    // for simplicity.
    when(dbmd.supportsMultipleResultSets()).thenReturn(false);
    final List<Object> results = fastResultSetHandler.handleResultSets(stmt);
    assertEquals(1, results.size());
    assertEquals(Integer.valueOf(100), ((HashMap) results.get(0)).get("cOlUmN1"));
}
Also used : ParameterHandler(org.apache.ibatis.executor.parameter.ParameterHandler) Executor(org.apache.ibatis.executor.Executor) BoundSql(org.apache.ibatis.mapping.BoundSql) RowBounds(org.apache.ibatis.session.RowBounds) MappedStatement(org.apache.ibatis.mapping.MappedStatement) ResultHandler(org.apache.ibatis.session.ResultHandler) Test(org.junit.Test)

Example 2 with ParameterHandler

use of org.apache.ibatis.executor.parameter.ParameterHandler in project pinpoint by naver.

the class BindingLogPlugin32 method getParameters.

private List<String> getParameters(MappedStatement ms, Object parameterObject, BoundSql boundSql) throws SQLException {
    // DefaultParameterHandler is the only implementation of parameterHandler interface currently. it may be changed later.
    // need additional codes to find a appropriate implementation in that case.
    ParameterHandler parameterHandler = new DefaultParameterHandler(ms, parameterObject, boundSql);
    PreparedStatementParameterLogger parameterLogger = new PreparedStatementParameterLogger();
    parameterHandler.setParameters(parameterLogger);
    return parameterLogger.getParameters();
}
Also used : ParameterHandler(org.apache.ibatis.executor.parameter.ParameterHandler) DefaultParameterHandler(org.apache.ibatis.scripting.defaults.DefaultParameterHandler) DefaultParameterHandler(org.apache.ibatis.scripting.defaults.DefaultParameterHandler)

Example 3 with ParameterHandler

use of org.apache.ibatis.executor.parameter.ParameterHandler in project mybatis-3 by mybatis.

the class Configuration method newParameterHandler.

public ParameterHandler newParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
    ParameterHandler parameterHandler = mappedStatement.getLang().createParameterHandler(mappedStatement, parameterObject, boundSql);
    parameterHandler = (ParameterHandler) interceptorChain.pluginAll(parameterHandler);
    return parameterHandler;
}
Also used : ParameterHandler(org.apache.ibatis.executor.parameter.ParameterHandler)

Aggregations

ParameterHandler (org.apache.ibatis.executor.parameter.ParameterHandler)3 Executor (org.apache.ibatis.executor.Executor)1 BoundSql (org.apache.ibatis.mapping.BoundSql)1 MappedStatement (org.apache.ibatis.mapping.MappedStatement)1 DefaultParameterHandler (org.apache.ibatis.scripting.defaults.DefaultParameterHandler)1 ResultHandler (org.apache.ibatis.session.ResultHandler)1 RowBounds (org.apache.ibatis.session.RowBounds)1 Test (org.junit.Test)1