We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7929fad commit 0db5de1Copy full SHA for 0db5de1
wiki/UseSqlMapper.md
@@ -70,6 +70,16 @@ SqlMapper sqlMapper = new SqlMapper(sqlSession);
70
71
在Service中使用的时候可以直接使用`@Autowired`注入。
72
73
+<b>注意:</b>`SqlMapper`增加了一个构造方法`public SqlMapper(SqlSession sqlSession, boolean cached)`,可以通过`cache`控制是否缓存动态创建的`MappedStatement`。
74
+
75
+使用`public SqlMapper(SqlSession sqlSession)`时,`cached`默认为`true`,会缓存。
76
77
+###如何选择是否缓存动态创建的`MappedStatement`?
78
79
+1. 当通过前台实现执行任意SQL时,建议关闭缓存,否则每一个SQL缓存一次,最终的缓存数量会很大
80
81
+2. 如果是业务代码中拼的sql,建议缓存提高效率
82
83
##简单例子
84
85
在`src/test/java`目录的`com.github.abel533.sql`包中包含这些方法的测试。
0 commit comments