3.mybatis的缓存是基于[namespace:sql语句:参数]来进行缓存的,意思就是,SqlSession的HashMap存储缓存数据时,是使用[namespace:sql:参数]作为key,查询返回的语句作为value保存的。例如:-1242243203:1146242777:winclpt.bean.userMapper.getUser:0:2147483647:select * from user where id=?:19
2018-08-27 22:01:39.732 DEBUG 6344 --- [nio-8033-exec-1] o.s.j.d.DataSourceTransactionManager : Switching JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@1af149f1] to manual commit 2018-08-27 22:01:39.740 INFO 6344 --- [nio-8033-exec-1] c.a.i.service.impl.StudentServiceImpl : 第一次查询 2018-08-27 22:01:39.743 DEBUG 6344 --- [nio-8033-exec-1] org.mybatis.spring.SqlSessionUtils : Creating a new SqlSession 2018-08-27 22:01:39.754 DEBUG 6344 --- [nio-8033-exec-1] org.mybatis.spring.SqlSessionUtils : Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@319fae52] Mon Aug 27 22:01:39 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 2018-08-27 22:01:39.807 DEBUG 6344 --- [nio-8033-exec-1] o.m.s.t.SpringManagedTransaction : JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@1af149f1] will be managed by Spring 2018-08-27 22:01:39.816 DEBUG 6344 --- [nio-8033-exec-1] c.a.i.d.S.selectByPrimaryKey : ==> Preparing: SELECT id,name,age,birth FROM student WHERE id = ? 2018-08-27 22:01:39.838 DEBUG 6344 --- [nio-8033-exec-1] c.a.i.d.S.selectByPrimaryKey : ==> Parameters: 2(String) 2018-08-27 22:01:39.864 DEBUG 6344 --- [nio-8033-exec-1] c.a.i.d.S.selectByPrimaryKey : <== Total: 1 耗时:104 ms - id:cn.acyou.iblogdata.dao.StudentMapper.selectByPrimaryKey <—————————————————————————SQL——————————————————————————> SELECT id,name,age,birth FROM student WHERE id = '2' <——————————————————————————————————————————————————————> 2018-08-27 22:01:39.865 DEBUG 6344 --- [nio-8033-exec-1] org.mybatis.spring.SqlSessionUtils : Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@319fae52] 2018-08-27 22:01:39.865 INFO 6344 --- [nio-8033-exec-1] c.a.i.service.impl.StudentServiceImpl : 第二次查询 2018-08-27 22:01:39.865 DEBUG 6344 --- [nio-8033-exec-1] org.mybatis.spring.SqlSessionUtils : Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@319fae52] from current transaction 耗时:1 ms - id:cn.acyou.iblogdata.dao.StudentMapper.selectByPrimaryKey <—————————————————————————SQL——————————————————————————> SELECT id,name,age,birth FROM student WHERE id = '2' <——————————————————————————————————————————————————————> 2018-08-27 22:01:39.866 DEBUG 6344 --- [nio-8033-exec-1] org.mybatis.spring.SqlSessionUtils : Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@319fae52]
2.mybatis的缓存是基于[namespace:sql语句:参数]来进行缓存的,意思就是,SqlSession的HashMap存储缓存数据时,是使用[namespace:sql:参数]作为key,查询返回的语句作为value保存的。例如:-1242243203:1146242777:winclpt.bean.userMapper.getUser:0:2147483647:select * from user where id=?:19