Mybatis常见疑问

1.在连接数据库时候,mysql是否支持fetchsize分页获取?

  满足以下几个条件,可以使用fetchsize,根据游标获得记录

  ①MySQL 从5.0.2开始支持分页获得.

  ②同时需要在jdbc连接参数上配置 jdbc:mysql://localhost:3306/test?useCursorFetch=true

  ③设置FetchSize,在mybatis的 具体查询语句中配置 。

  

  在MySQL的JDBC源码中:MysqlIO中

   //版本>=5.0.2 && 连接上配置useCurSorFetch=true &&isBinaryEncoded =true &&
 (.connection.versionMeetsMinimum(5,2) && .connection.getUseCursorFetch() && isBinaryEncoded && callingStatement != 
                 && callingStatement.getFetchSize() != 0 && callingStatement.getResultSetType() ==             ServerPreparedStatement prepStmt = 
              usingCursor =  
             
                                        
              (.connection.versionMeetsMinimum(5,5                 usingCursor = (.serverStatus & SERVER_STATUS_CURSOR_EXISTS) != 0  
                              RowData rows =  RowDataCursor( 
                 ResultSetImpl rs = 
                    
                           }

2.Mybatis开启Mapper级别的缓存时,注意Bean需要继承Serializer接口

相关文章

1.pom.xml引入依赖 <dependency> <gro...
<?xml version="1.0" encoding=&a...
准备工作 ① 创建数据库&数据表 ## 创建数据库 CREA...
MyBatis逆向工程是指根据数据库表结构自动生成对应的实体类、...
MyBatis获取参数值的两种方式:${}和#{} ${}的本质就是字符串...
resultMap作用是处理数据表中字段与java实体类中属性的映射关...