File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,16 @@ mapperHelper.processConfiguration(session.getConfiguration());
51
51
</bean >
52
52
```
53
53
54
- <b >你没看错,就是这么配置的,注意这里是` tk.mybatis ` ,通用Mapper的各项属性通过` properties ` 属性进行配置。</b >
54
+ <b >你没看错,就是这么配置的,注意这里是` tk.mybatis.xxx ` ,和MyBatis的唯一区别就是` org. ` 改成了` tk. ` ,方便修改和记忆。
55
+
56
+ 通用Mapper的各项属性通过` properties ` 属性进行配置,如果默认配置就是一行` mappers=tk.mybatis.mapper.common.Mapper ` 时,可以不写,就会变成:
57
+
58
+ ``` xml
59
+ <bean class =" tk.mybatis.spring.mapper.MapperScannerConfigurer" >
60
+ <property name =" basePackage" value =" com.isea533.mybatis.mapper" />
61
+ </bean >
62
+ ```
63
+
55
64
56
65
###INENTITY参数配置(仅对 insert 有用)
57
66
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ Mapper3接口有两种形式,一种是提供了一个方法的接口。还有
17
17
说明:根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号<br >
18
18
<br >
19
19
20
+ 接口:` SelectAllMapper<T> ` <br >
21
+ 方法:` List<T> selectAll(); ` <br >
22
+ 说明:查询全部结果,select(null)方法能达到同样的效果<br >
23
+ <br >
24
+
20
25
接口:` SelectOneMapper<T> ` <br >
21
26
方法:` T selectOne(T record); ` <br >
22
27
说明:根据实体中的属性进行查询,只能有一个返回值,有多个结果是抛出异常,查询条件使用等号<br ><br >
@@ -78,7 +83,9 @@ Mapper3接口有两种形式,一种是提供了一个方法的接口。还有
78
83
79
84
接口:` SelectByExampleMapper<T> ` <br >
80
85
方法:` List<T> selectByExample(Object example); ` <br >
81
- 说明:根据Example条件进行查询<br ><br >
86
+ 说明:根据Example条件进行查询<br >
87
+ <b >重点:</b >这个查询支持通过` Example ` 类指定查询列,通过` selectProperties ` 方法指定查询列<br ><br >
88
+
82
89
83
90
接口:` SelectCountByExampleMapper<T> ` <br >
84
91
方法:` int selectCountByExample(Object example); ` <br >
Original file line number Diff line number Diff line change @@ -26,14 +26,14 @@ public interface InsertListMapper<T> {
26
26
public String insertList(MappedStatement ms) {
27
27
final Class<?> entityClass = getSelectReturnType(ms);
28
28
// 获取表的各项属性
29
- EntityHelper . EntityTable table = EntityHelper . getEntityTable(entityClass);
29
+ EntityTable table = getEntityTable(entityClass);
30
30
// 开始拼sql
31
31
StringBuilder sql = new StringBuilder ();
32
32
sql. append(" insert into " );
33
33
sql. append(table. getName());
34
34
sql. append(" (" );
35
35
boolean first = true ;
36
- for (EntityHelper . EntityColumn column : table. getEntityClassColumns()) {
36
+ for (EntityColumn column : table. getEntityClassColumns()) {
37
37
if (! first) {
38
38
sql. append(" ," );
39
39
}
@@ -44,7 +44,7 @@ public String insertList(MappedStatement ms) {
44
44
sql. append(" <foreach collection=\" list\" item=\" record\" separator=\" ,\" >" );
45
45
sql. append(" (" );
46
46
first = true ;
47
- for (EntityHelper . EntityColumn column : table. getEntityClassColumns()) {
47
+ for (EntityColumn column : table. getEntityClassColumns()) {
48
48
if (! first) {
49
49
sql. append(" ," );
50
50
}
You can’t perform that action at this time.
0 commit comments