当前位置: 首页>>代码示例>>Java>>正文


Java ParameterHandler类代码示例

本文整理汇总了Java中org.apache.ibatis.executor.parameter.ParameterHandler的典型用法代码示例。如果您正苦于以下问题:Java ParameterHandler类的具体用法?Java ParameterHandler怎么用?Java ParameterHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParameterHandler类属于org.apache.ibatis.executor.parameter包,在下文中一共展示了ParameterHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DefaultResultSetHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
public DefaultResultSetHandler(Executor executor, MappedStatement mappedStatement, ParameterHandler parameterHandler, ResultHandler<?> resultHandler, BoundSql boundSql,
    RowBounds rowBounds) {
  this.executor = executor;
  this.configuration = mappedStatement.getConfiguration();
  this.mappedStatement = mappedStatement;
  this.rowBounds = rowBounds;
  this.parameterHandler = parameterHandler;
  this.boundSql = boundSql;
  this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
  this.objectFactory = configuration.getObjectFactory();
  this.reflectorFactory = configuration.getReflectorFactory();
  this.resultHandler = resultHandler;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:14,代码来源:DefaultResultSetHandler.java

示例2: shouldRetainColumnNameCase

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
/**
 * 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);
  when(dbmd.supportsMultipleResultSets()).thenReturn(false); // for simplicity.

  final List<Object> results = fastResultSetHandler.handleResultSets(stmt);
  assertEquals(1, results.size());
  assertEquals(Integer.valueOf(100), ((HashMap) results.get(0)).get("cOlUmN1"));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:36,代码来源:DefaultResultSetHandlerTest.java

示例3: DefaultResultSetHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
public DefaultResultSetHandler(Executor executor, MappedStatement mappedStatement, ParameterHandler parameterHandler, ResultHandler resultHandler, BoundSql boundSql,
    RowBounds rowBounds) {
  this.executor = executor;
  this.configuration = mappedStatement.getConfiguration();
  this.mappedStatement = mappedStatement;
  this.rowBounds = rowBounds;
  this.parameterHandler = parameterHandler;
  this.boundSql = boundSql;
  this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
  this.objectFactory = configuration.getObjectFactory();
  this.resultHandler = resultHandler;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:13,代码来源:DefaultResultSetHandler.java

示例4: getTotalCount

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
/**
 * 获取总记录数
 *
 * @param sql      原始sql语句
 * @param conn
 * @param ms
 * @param boundSql
 * @return
 * @throws SQLException
 */
private int getTotalCount(String sql, Connection conn, MappedStatement ms, BoundSql boundSql) throws SQLException {
  int start = sql.indexOf("from");
  if (start == -1) {
    throw new RuntimeException("statement has no 'from' keyword");
  }
  int stop = sql.indexOf("order by");
  if (stop == -1) {
    stop = sql.length();
  }

  String countSql = "select count(0) " + sql.substring(start, stop);
  BoundSql countBoundSql = new BoundSql(ms.getConfiguration(), countSql, boundSql.getParameterMappings(), boundSql.getParameterObject());
  ParameterHandler parameterHandler = new DefaultParameterHandler(ms, boundSql.getParameterObject(), countBoundSql);
  PreparedStatement stmt = null;
  ResultSet rs = null;
  int count = 0;
  try {
    stmt = conn.prepareStatement(countSql);
    // 通过parameterHandler给PreparedStatement对象设置参数
    parameterHandler.setParameters(stmt);
    rs = stmt.executeQuery();
    if (rs.next()) {
      count = rs.getInt(1);
    }
  } finally {
    CloseableUtil.closeQuietly(rs);
    CloseableUtil.closeQuietly(stmt);
  }
  return count;
}
 
开发者ID:colin-lee,项目名称:mybatis-spring-support,代码行数:41,代码来源:PaginationAutoMapInterceptor.java

示例5: FastResultSetHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
public FastResultSetHandler(Executor executor, MappedStatement mappedStatement, ParameterHandler parameterHandler, ResultHandler resultHandler, BoundSql boundSql, RowBounds rowBounds) {
  this.executor = executor;
  this.configuration = mappedStatement.getConfiguration();
  this.mappedStatement = mappedStatement;
  this.rowBounds = rowBounds;
  this.parameterHandler = parameterHandler;
  this.boundSql = boundSql;
  this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
  this.objectFactory = configuration.getObjectFactory();
  this.resultHandler = resultHandler;
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:12,代码来源:FastResultSetHandler.java

示例6: getParameters

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
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();
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:9,代码来源:BindingLogPlugin32.java

示例7: DefaultResultSetHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
public DefaultResultSetHandler(Executor executor, MappedStatement mappedStatement, ParameterHandler parameterHandler, ResultHandler<?> resultHandler, BoundSql boundSql,
                               RowBounds rowBounds) {
  this.executor = executor;
  this.configuration = mappedStatement.getConfiguration();
  this.mappedStatement = mappedStatement;
  this.rowBounds = rowBounds;
  this.parameterHandler = parameterHandler;
  this.boundSql = boundSql;
  this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
  this.objectFactory = configuration.getObjectFactory();
  this.reflectorFactory = configuration.getReflectorFactory();
  this.resultHandler = resultHandler;
  this.primitiveTypes = new PrimitiveTypes();
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:15,代码来源:DefaultResultSetHandler.java

示例8: createParameterHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
@Override
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
                                               BoundSql boundSql) {
    /* 使用自定义 ParameterHandler */
    return new MybatisDefaultParameterHandler(mappedStatement, parameterObject, boundSql);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:7,代码来源:MybatisXMLLanguageDriver.java

示例9: createParameterHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
@Override
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
  return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:5,代码来源:XMLLanguageDriver.java

示例10: getParameterHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
@Override
public ParameterHandler getParameterHandler() {
  return delegate.getParameterHandler();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:5,代码来源:RoutingStatementHandler.java

示例11: getParameterHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
@Override
public ParameterHandler getParameterHandler() {
  return parameterHandler;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:5,代码来源:BaseStatementHandler.java

示例12: intercept

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
    StopWatch stopWatch = new StopWatch("MyBatis Pagination Plugin");

    stopWatch.start("Get page object");

    StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
    MetaObject metaObject = SystemMetaObject.forObject(statementHandler);

    Pagination page = null;
    ParameterHandler parameterHandler = statementHandler.getParameterHandler();
    Object parameterObject = parameterHandler.getParameterObject();
    if (parameterObject instanceof Map) {
        @SuppressWarnings("unchecked")
        Map<String, Object> params = (Map<String, Object>) parameterObject;
        for (Map.Entry<String, Object> entry : params.entrySet()) {
            Object parameter = entry.getValue();
            if (parameter instanceof Pagination) {
                page = (Pagination) parameter;
                break;
            }
        }
    }

    stopWatch.stop();

    if (page == null) {
        return invocation.proceed();
    }

    stopWatch.start("Count result");

    String originSql = statementHandler.getBoundSql().getSql();
    logger.debug("Original SQL: {}", originSql);

    // 查询总记录数
    Configuration configuration = (Configuration) metaObject.getValue(DELEGATE_CONFIGURATION);
    int rowCount = getQueryCount(configuration, statementHandler);

    stopWatch.stop();

    // 根据查询得到的总记录数初始化分页对象
    page.setRowCount(rowCount);
    page.initialize();

    stopWatch.start("Generate page sql");

    // 分页查询 本地化对象 修改数据库注意修改实现
    String pageSql = generatePageSql(originSql, page, dialect);
    logger.debug("Pagination SQL: {}", pageSql);

    metaObject.setValue(DELEGATE_BOUND_SQL, pageSql);
    metaObject.setValue(DELEGATE_ROW_BOUNDS_OFFSET, RowBounds.NO_ROW_OFFSET);
    metaObject.setValue(DELEGATE_ROW_BOUNDS_LIMIT, RowBounds.NO_ROW_LIMIT);

    stopWatch.stop();

    if (logger.isDebugEnabled()) {
        logger.debug(stopWatch.prettyPrint());
    }

    return invocation.proceed();
}
 
开发者ID:akuma,项目名称:meazza,代码行数:64,代码来源:MyBatisPagePlugin.java

示例13: createParameterHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
@Override
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
    return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
}
 
开发者ID:hatunet,项目名称:mybatis-beetl-scripting,代码行数:5,代码来源:Driver.java

示例14: createParameterHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
@Override
 public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
   //返回默认的参数处理器
return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
 }
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:6,代码来源:XMLLanguageDriver.java

示例15: createParameterHandler

import org.apache.ibatis.executor.parameter.ParameterHandler; //导入依赖的package包/类
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
  return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:4,代码来源:VelocityLanguageDriver.java


注:本文中的org.apache.ibatis.executor.parameter.ParameterHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。