PageHelper只对紧跟着的第一条SQL起作用
生活随笔
收集整理的這篇文章主要介紹了
PageHelper只对紧跟着的第一条SQL起作用
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
這個sql的中心思想就是根據(jù)查詢到的schema然后分別查詢schema中的相關(guān)數(shù)據(jù)再用union all將結(jié)果及拼接在一起。
LocServiceImpl.findAllLoc(Loc loc) @Overridepublic List<Loc> findAllLoc(Loc loc) {try {HashMap<String,Object> map = new HashMap<String,Object>();List<String> schemas = this.locMapper.findAllSchema(loc);//查詢所有的schemamap.put("schemas", schemas);map.put("loc", loc);return this.locMapper.findAllLoc(map);} catch (Exception e) {e.printStackTrace();return new ArrayList<>();}}
LocServiceImpl.findAllLoc(Loc loc) @Overridepublic List<Loc> findAllLoc(Loc loc) {try {HashMap<String,Object> map = new HashMap<String,Object>();List<String> schemas = this.locMapper.findAllSchema(loc);//查詢所有的schemamap.put("schemas", schemas);map.put("loc", loc);return this.locMapper.findAllLoc(map);} catch (Exception e) {e.printStackTrace();return new ArrayList<>();}}
//分頁異常的代碼的LocController中代碼
@RequestMapping("loc/list")@ResponseBodypublic Map<String, Object> locList(QueryRequest request, Loc loc) {PageHelper.startPage(request.getPageNum(), request.getPageSize());List<Loc> list = this.locService.findAllLoc(loc);//具體實現(xiàn)在第一段代碼。系統(tǒng)認為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: oraclereasonable: false//這個熟悉需要改成falsesupportMethodsArguments: trueparams: count=countSql?//分頁正常的LocController中代碼,拆分開,然后把PageHelper放在需要分頁的SQL之前,就正常了。
@RequestMapping("loc/list")@ResponseBodypublic 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);}?
轉(zhuǎn)載于:https://www.cnblogs.com/CryOnMyShoulder/p/11428476.html
總結(jié)
以上是生活随笔為你收集整理的PageHelper只对紧跟着的第一条SQL起作用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [Swift]LeetCode1153.
- 下一篇: ORA-01102