PageHelper自定义count
生活随笔
收集整理的這篇文章主要介紹了
PageHelper自定义count
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用場景
web頁面的查詢功能太復雜,pageHelper自動生成的count語句相當于在查詢語句外包一層count,查詢速度比較慢。需要優化count語句,所以才想起來自定義count語句。
版本要求
5.0.4版本及以上
<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>5.0.4</version> </dependency>使用方式
原有的代碼不需要動,只需要在mybatis的xml文件里添加一個count查詢
這里注意以下三點即可:
查詢語句
<select id="searchAllCondition" parameterType="com.demo.MyForm" resultMap="SearchResultMap">select name,age,sex from student </select>count語句
<select id="searchAllCondition_COUNT" parameterType="com.demo.MyForm" resultType="Long">select count(1) from student </select>注意以上demo兩個語句的區別
官方文檔
https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Changelog.md#504—2017-08-01
總結
以上是生活随笔為你收集整理的PageHelper自定义count的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pytorch BCEWithLogit
- 下一篇: 无线传感网络——串口通信