zoukankan      html  css  js  c++  java
  • PageHelper只对紧跟着的第一条SQL起作用

    这个sql的中心思想就是根据查询到的schema然后分别查询schema中的相关数据再用union all将结果及拼接在一起。
    LocServiceImpl.findAllLoc(Loc loc)
    @Override
        public List<Loc> findAllLoc(Loc loc) {
            try {
                HashMap<String,Object> map = new HashMap<String,Object>();
                List<String> schemas = this.locMapper.findAllSchema(loc);//查询所有的schema
                map.put("schemas", schemas);
                map.put("loc", loc);
                return this.locMapper.findAllLoc(map);
            } catch (Exception e) {
                e.printStackTrace();
                return new ArrayList<>();
            }
        }

    //分页异常的代码的LocController中代码

    @RequestMapping("loc/list")
        @ResponseBody
        public Map<String, Object> locList(QueryRequest request, Loc loc) {
            PageHelper.startPage(request.getPageNum(), request.getPageSize());
            List<Loc> list = this.locService.findAllLoc(loc);//具体实现在第一段代码。系统认为findAllSchema(loc)是第一条语句。PageHelper只对紧跟着的第一条SQL起作用
    
    //        HashMap<String,Object> map = new HashMap<String,Object>();
    //        List<String> schemas = this.locMapper.findAllSchema(loc);//        map.put("schemas", schemas);
    //        map.put("loc", loc);
    //        
    //        PageHelper.startPage(request.getPageNum(), request.getPageSize());
    //        List<Loc> list =  this.locMapper.findAllLoc(map);
            
            PageInfo<Loc> pageInfo = new PageInfo<>(list);
            return getDataTable(pageInfo);
        }

    //yml配置

    #pagehelper
    pagehelper: 
      helperDialect: oracle
      reasonable: false//这个熟悉需要改成false
      supportMethodsArguments: true
      params: count=countSql 

     //分页正常的LocController中代码,拆分开,然后把PageHelper放在需要分页的SQL之前,就正常了。

    @RequestMapping("loc/list")
        @ResponseBody
        public Map<String, Object> locList(QueryRequest request, Loc loc) {
    //        PageHelper.startPage(request.getPageNum(), request.getPageSize());
    //        List<Loc> list = this.locService.findAllLoc(loc);
    
            HashMap<String,Object> map = new HashMap<String,Object>();
            List<String> schemas = this.locMapper.findAllSchema(loc);
            map.put("schemas", schemas);
            map.put("loc", loc);
            PageHelper.startPage(request.getPageNum(), request.getPageSize());//PageHelper只对紧跟着的第一条SQL起作用
            List<Loc> list =  this.locMapper.findAllLoc(map);//这条语句被视为紧跟着的第一条语句
            
            PageInfo<Loc> pageInfo = new PageInfo<>(list);
            return getDataTable(pageInfo);
        }
  • 相关阅读:
    IntelliJ IDEA注册码
    linux中patch命令 -p 选项
    设备文件简介
    《算法导论》——矩阵
    《算法导论》——数论
    linux常用查看硬件设备信息命令(转载)
    netstat和telnet命令在Windows7中的用法(转载)
    c++容器使用总结(转载)
    离散数学——数论算法
    c语言中内存对齐问题
  • 原文地址:https://www.cnblogs.com/CryOnMyShoulder/p/11428476.html
Copyright © 2011-2022 走看看