示例#1
0
 /**
  * @description TODO
  * @createTime 2016-4-19 上午11:20:47
  * @fileName CacheInterceptor.java
  * @author yaojiamin
  */
 private BoundSql createPageBoundSql(CacheHandlerBean cacheHandlerBean, BoundSql boundSql) {
   return new BoundSql(
       cacheHandlerBean.getMappedStatement().getConfiguration(),
       createCountSql(boundSql),
       boundSql.getParameterMappings(),
       cacheHandlerBean.getParameterObject());
 }
示例#2
0
 /**
  * @description TODO
  * @createTime 2016-4-27 下午12:33:11
  * @fileName CacheInterceptor.java
  * @author yaojiamin
  */
 private <E> List<E> executeQuery(
     CacheHandlerBean cacheHandlerBean, BoundSql boundSql, CacheKey cacheKey, Executor executor)
     throws SQLException {
   return executor.query(
       cacheHandlerBean.getMappedStatement(),
       cacheHandlerBean.getParameterObject(),
       cacheHandlerBean.getRowBounds(),
       cacheHandlerBean.getResultHandler(),
       cacheKey,
       boundSql);
 }
示例#3
0
 /**
  * @description TODO
  * @createTime 2016-5-31 下午4:53:32
  * @fileName CacheInterceptor.java
  * @author yaojiamin
  * @param boundSql
  * @param cacheKey
  */
 @SuppressWarnings({})
 public <E> List<E> query(Executor executor, CacheHandlerBean cacheHandlerBean) throws Exception {
   BoundSql boundSql =
       cacheHandlerBean.getMappedStatement().getBoundSql(cacheHandlerBean.getParameterObject());
   CacheKey cacheKey =
       executor.createCacheKey(
           cacheHandlerBean.getMappedStatement(),
           cacheHandlerBean.getParameterObject(),
           cacheHandlerBean.getRowBounds(),
           boundSql);
   MetaObject metaPage = forObject(cacheHandlerBean.getParameterObject());
   // 当需要分页查询时,将page参数里的当前页和每页数加到cachekey里
   if (isNeedPagination(metaPage)) {
     executeQuery(
         cacheHandlerBean,
         createPageBoundSql(cacheHandlerBean, boundSql),
         cloneCacheKey(cacheKey),
         executor);
     Assert.isTrue(metaPage.getValue(Constants.TOTAL) != null, "Fail to count result!!!");
     cacheKey.update(metaPage.getValue(Constants.PAGE_NO));
     cacheKey.update(metaPage.getValue(Constants.PAGE_SIZE));
   }
   return executeQuery(cacheHandlerBean, boundSql, cacheKey, executor);
 }