首页 > 其他 > 详细

PageHelper大致逻辑

时间:2021-01-20 15:18:23      阅读:29      评论:0      收藏:0      [点我收藏+]

简单涉及以下几个类:

  PageHelper   PageMethod  PageParam   

  PageInterceptor  implement Interceptor

  PageHelperAutoConfiguration  implements EnvironmentAware

主要逻辑

  启动系统时,

       1.因为PageInterceptor实现了Interceptor,所以系统会初始化PageInterceptor.setProperties(Properties properties)方法,

技术分享图片

 

                          注:@Signature注解对应的Executor.query的两个方法,当PageHelper生效后,将拦截这两个方法对应的Mapper映射器方法

       2.PageHelperAutoConfiguration.addPageInterceptor()上有@PostCOnstruct注解,所以会初始化此方法,

技术分享图片

 

                       将interceptor加入当前sqlSesson拦截器列表中

 

  调用PageHelper.startPage(pageNum,pageSize)时

           1.系统会拦截到第一个Mapper查询数据的get方法,因为该方法最终是通过Executor.query执行

           2.拦截到该方法后,加入分页逻辑,当执行完sql返回结果后,pageHelper(通过pageMethod)清空分页缓存

          

======================================================================================

    Mapper初始化操作是通过MapperProxy处理的

======================================================================================

 

PageHelper大致逻辑

原文:https://www.cnblogs.com/qlsty/p/14302542.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!