org.apache.ibatis.executor.Executor.query()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(234)

本文整理了Java中org.apache.ibatis.executor.Executor.query()方法的一些代码示例,展示了Executor.query()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executor.query()方法的具体详情如下:
包路径:org.apache.ibatis.executor.Executor
类名称:Executor
方法名:query

Executor.query介绍

暂无

代码示例

代码示例来源:origin: pagehelper/Mybatis-PageHelper

/**
 * 执行手动设置的 count 查询,该查询支持的参数必须和被分页的方法相同
 *
 * @param executor
 * @param countMs
 * @param parameter
 * @param boundSql
 * @param resultHandler
 * @return
 * @throws SQLException
 */
public static Long executeManualCount(Executor executor, MappedStatement countMs,
                   Object parameter, BoundSql boundSql,
                   ResultHandler resultHandler) throws SQLException {
  CacheKey countKey = executor.createCacheKey(countMs, parameter, RowBounds.DEFAULT, boundSql);
  BoundSql countBoundSql = countMs.getBoundSql(parameter);
  Object countResultList = executor.query(countMs, parameter, RowBounds.DEFAULT, resultHandler, countKey, countBoundSql);
  Long count = ((Number) ((List) countResultList).get(0)).longValue();
  return count;
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

return executor.query(ms, parameter, RowBounds.DEFAULT, resultHandler, pageKey, pageBoundSql);
} else {
  return executor.query(ms, parameter, RowBounds.DEFAULT, resultHandler, cacheKey, boundSql);

代码示例来源:origin: pagehelper/Mybatis-PageHelper

@Override
public Object intercept(Invocation invocation) throws Throwable {
  Object[] args = invocation.getArgs();
  MappedStatement ms = (MappedStatement) args[0];
  Object parameter = args[1];
  RowBounds rowBounds = (RowBounds) args[2];
  ResultHandler resultHandler = (ResultHandler) args[3];
  Executor executor = (Executor) invocation.getTarget();
  CacheKey cacheKey;
  BoundSql boundSql;
  //由于逻辑关系,只会进入一次
  if(args.length == 4){
    //4 个参数时
    boundSql = ms.getBoundSql(parameter);
    cacheKey = executor.createCacheKey(ms, parameter, rowBounds, boundSql);
  } else {
    //6 个参数时
    cacheKey = (CacheKey) args[4];
    boundSql = (BoundSql) args[5];
  }
  //TODO 自己要进行的各种处理
  //注:下面的方法可以根据自己的逻辑调用多次,在分页插件中,count 和 page 各调用了一次
  return executor.query(ms, parameter, rowBounds, resultHandler, cacheKey, boundSql);
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

Object countResultList = executor.query(countMs, parameter, RowBounds.DEFAULT, resultHandler, countKey, countBoundSql);
Long count = (Long) ((List) countResultList).get(0);
return count;

代码示例来源:origin: abel533/Mapper

List<Object> values = keyExecutor.query(keyStatement, parameter, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if (values.size() == 0) {
  throw new ExecutorException("SelectKey returned no data.");

代码示例来源:origin: abel533/Mapper

List<Object> values = keyExecutor.query(keyStatement, parameter, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if (values.size() == 0) {
  throw new ExecutorException("SelectKey returned no data.");

代码示例来源:origin: pagehelper/Mybatis-PageHelper

} else {
  resultList = executor.query(ms, parameter, rowBounds, resultHandler, cacheKey, boundSql);

代码示例来源:origin: camunda/camunda-bpm-platform

private <E> List<E> selectList() throws SQLException {
 Executor localExecutor = executor;
 if (Thread.currentThread().getId() != this.creatorThreadId || localExecutor.isClosed()) {
  localExecutor = newExecutor();
 }
 try {
  return localExecutor.<E> query(mappedStatement, parameterObject, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER, cacheKey, boundSql);
 } finally {
  if (localExecutor != executor) {
   localExecutor.close(false);
  }
 }
}

代码示例来源:origin: org.mybatis/mybatis

private <E> List<E> selectList() throws SQLException {
 Executor localExecutor = executor;
 if (Thread.currentThread().getId() != this.creatorThreadId || localExecutor.isClosed()) {
  localExecutor = newExecutor();
 }
 try {
  return localExecutor.<E> query(mappedStatement, parameterObject, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER, cacheKey, boundSql);
 } finally {
  if (localExecutor != executor) {
   localExecutor.close(false);
  }
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public <E> List<E> query(MappedStatement ms, Object parameterObject, RowBounds rowBounds, ResultHandler resultHandler, CacheKey key, BoundSql boundSql)
  throws SQLException {
 Cache cache = ms.getCache();
 if (cache != null) {
  flushCacheIfRequired(ms);
  if (ms.isUseCache() && resultHandler == null) {
   ensureNoOutParams(ms, parameterObject, boundSql);
   @SuppressWarnings("unchecked")
   List<E> list = (List<E>) tcm.getObject(cache, key);
   if (list == null) {
    list = delegate.<E> query(ms, parameterObject, rowBounds, resultHandler, key, boundSql);
    tcm.putObject(cache, key, list); // issue #578 and #116
   }
   return list;
  }
 }
 return delegate.<E> query(ms, parameterObject, rowBounds, resultHandler, key, boundSql);
}

代码示例来源:origin: org.mybatis/mybatis

@Override
public <E> List<E> query(MappedStatement ms, Object parameterObject, RowBounds rowBounds, ResultHandler resultHandler, CacheKey key, BoundSql boundSql)
  throws SQLException {
 Cache cache = ms.getCache();
 if (cache != null) {
  flushCacheIfRequired(ms);
  if (ms.isUseCache() && resultHandler == null) {
   ensureNoOutParams(ms, boundSql);
   @SuppressWarnings("unchecked")
   List<E> list = (List<E>) tcm.getObject(cache, key);
   if (list == null) {
    list = delegate.query(ms, parameterObject, rowBounds, resultHandler, key, boundSql);
    tcm.putObject(cache, key, list); // issue #578 and #116
   }
   return list;
  }
 }
 return delegate.query(ms, parameterObject, rowBounds, resultHandler, key, boundSql);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
 try {
  MappedStatement ms = configuration.getMappedStatement(statement);
  executor.query(ms, wrapCollection(parameter), rowBounds, handler);
 } catch (Exception e) {
  throw ExceptionFactory.wrapException("Error querying database.  Cause: " + e, e);
 } finally {
  ErrorContext.instance().reset();
 }
}

代码示例来源:origin: org.mybatis/mybatis

@Override
public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
 try {
  MappedStatement ms = configuration.getMappedStatement(statement);
  executor.query(ms, wrapCollection(parameter), rowBounds, handler);
 } catch (Exception e) {
  throw ExceptionFactory.wrapException("Error querying database.  Cause: " + e, e);
 } finally {
  ErrorContext.instance().reset();
 }
}

代码示例来源:origin: org.mybatis/mybatis

@Override
public <E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds) {
 try {
  MappedStatement ms = configuration.getMappedStatement(statement);
  return executor.query(ms, wrapCollection(parameter), rowBounds, Executor.NO_RESULT_HANDLER);
 } catch (Exception e) {
  throw ExceptionFactory.wrapException("Error querying database.  Cause: " + e, e);
 } finally {
  ErrorContext.instance().reset();
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public <E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds) {
 try {
  MappedStatement ms = configuration.getMappedStatement(statement);
  return executor.query(ms, wrapCollection(parameter), rowBounds, Executor.NO_RESULT_HANDLER);
 } catch (Exception e) {
  throw ExceptionFactory.wrapException("Error querying database.  Cause: " + e, e);
 } finally {
  ErrorContext.instance().reset();
 }
}

代码示例来源:origin: mybatis-book/book

@SuppressWarnings("rawtypes")
@Override
public Object intercept(Invocation invocation) throws Throwable {
  Executor executor = (Executor)invocation.getTarget();
  Object[] args = invocation.getArgs();
  MappedStatement ms = (MappedStatement)args[0];
  Object parameterObject = args[1];
  RowBounds rowBounds = (RowBounds)args[2];
  ResultHandler resultHandler = (ResultHandler)args[3];
  BoundSql boundSql = ms.getBoundSql(parameterObject);
  CacheKey pageKey = null, countKey = null;
  if(executor instanceof CachingExecutor){
    pageKey = ((CachingExecutor)executor).createCacheKey(ms, parameterObject, rowBounds, boundSql);
    countKey = ((CachingExecutor)executor).createCacheKey(ms, parameterObject, rowBounds, boundSql);
  } else {
    pageKey = ((BaseExecutor)executor).createCacheKey(ms, parameterObject, rowBounds, boundSql);
    countKey = ((BaseExecutor)executor).createCacheKey(ms, parameterObject, rowBounds, boundSql);
  }
  countKey.update("Count");
  BoundSql countSql = new BoundSql(ms.getConfiguration(), "select count(*) from (" + boundSql.getSql() + ") temp", boundSql.getParameterMappings(), parameterObject);
  Object r2 = executor.query(ms, parameterObject, rowBounds, resultHandler, pageKey, boundSql);
  MappedStatement countMs = newMappedStatement(ms, Long.class);
  Object r1 = executor.query(countMs, parameterObject, rowBounds, resultHandler, countKey, countSql);
  System.out.println(r1);
  return r2;
}

代码示例来源:origin: camunda/camunda-bpm-platform

List<Object> values = keyExecutor.query(keyStatement, parameter, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if (values.size() == 0) {
 throw new ExecutorException("SelectKey returned no data.");

代码示例来源:origin: org.mybatis/mybatis

List<Object> values = keyExecutor.query(keyStatement, parameter, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if (values.size() == 0) {
 throw new ExecutorException("SelectKey returned no data.");

代码示例来源:origin: mybatis-book/book

Object countResultList = executor.query(
    countMs, 
    parameterObject, 
List resultList = executor.query(
    ms, 
    parameterObject,

代码示例来源:origin: org.apache.ibatis/ibatis-core

public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
 try {
  MappedStatement ms = configuration.getMappedStatement(statement);
  executor.query(ms, wrapCollection(parameter), rowBounds, handler);
 } catch (Exception e) {
  throw ExceptionFactory.wrapException("Error querying database.  Cause: " + e, e);
 } finally {
  ErrorContext.instance().reset();
 }
}

相关文章