10000 解决 MapperHelper.setConfig 方法中没有处理 mappers 的 BUG,主要影响 starter 中的使用。 · coderliguoqing/Mapper@fefe5df · GitHub
[go: up one dir, main page]

Skip to content

Commit fefe5df

Browse files
committed
解决 MapperHelper.setConfig 方法中没有处理 mappers 的 BUG,主要影响 starter 中的使用。
升级版本到 3.5.3。
1 parent af04696 commit fefe5df

File tree

4 files changed

+55
-20
lines changed

4 files changed

+55
-20
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<groupId>tk.mybatis</groupId>
3030
<artifactId>mapper</artifactId>
31-
<version>3.5.2</version>
31+
<version>3.5.3</version>
3232
<packaging>jar</packaging>
3333

3434
<name>mapper</name>

src/main/java/tk/mybatis/mapper/entity/Config.java

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import tk.mybatis.mapper.util.SimpleTypeUtil;
3131
import tk.mybatis.mapper.util.StringUtil;
3232

33+
import java.util.ArrayList;
34+
import java.util.List;
3335
import java.util.Properties;
3436

3537
/**
@@ -38,6 +40,9 @@
3840
* @author liuzh
3941
*/
4042
public class Config {
43+
public static final String PREFIX = "mapper";
44+
45+
private List<Class> mappers = new ArrayList<Class>();
4146
private String UUID;
4247
private String IDENTITY;
4348
private boolean BEFORE;
@@ -52,15 +57,15 @@ public class Config {
5257
/**
5358
* @since 3.5.0
5459
*/
55-
private boolean enumAsSimpleType = false;
60+
private boolean enumAsSimpleType;
5661
/**
5762
* 是否支持方法上的注解,默认false
5863
*/
5964
private boolean enableMethodAnnotation;
6065
/**
6166
* 对于一般的getAllIfColumnNode,是否判断!='',默认不判断
6267
*/
63-
private boolean notEmpty = false;
68+
private boolean notEmpty;
6469
/**
6570
* 字段转换风格,默认驼峰转下划线
6671
*/
@@ -262,6 +267,38 @@ public void setOrder(String order) {
262267
this.BEFORE = "BEFORE".equalsIgnoreCase(order);
263268
}
264269

270+
public String getIdentity() {
271+
return getIDENTITY();
272+
}
273+
274+
public void setIdentity(String identity) {
275+
setIDENTITY(identity);
276+
}
277+
278+
public List<Class> getMappers() {
279+
return mappers;
280+
}
281+
282+
public void setMappers(List<Class> mappers) {
283+
this.mappers = mappers;
284+
}
285+
286+
public String getUuid() {
287+
return getUUID();
288+
}
289+
290+
public void setUuid(String uuid) {
291+
setUUID(uuid);
292+
}
293+
294+
public boolean isBefore() {
295+
return isBEFORE();
296+
}
297+
298+
public void setBefore(boolean before) {
299+
setBEFORE(before);
300+
}
301+
265302
/**
266303
* 配置属性
267304
*
@@ -297,26 +334,15 @@ public void setProperties(Properties properties) {
297334
if (StringUtil.isNotEmpty(ORDER)) {
298335
setOrder(ORDER);
299336
}
300-
String notEmpty = properties.getProperty("notEmpty");
301-
if (StringUtil.isNotEmpty(notEmpty)) {
302-
this.notEmpty = notEmpty.equalsIgnoreCase("TRUE");
303-
}
304-
String enableMethodAnnotation = properties.getProperty("enableMethodAnnotation");
305-
if (StringUtil.isNotEmpty(enableMethodAnnotation)) {
306-
this.enableMethodAnnotation = enableMethodAnnotation.equalsIgnoreCase("TRUE");
307-
}
308-
String checkExampleStr = properties.getProperty("checkExampleEntityClass");
309-
if (StringUtil.isNotEmpty(checkExampleStr)) {
310-
this.checkExampleEntityClass = checkExampleStr.equalsIgnoreCase("TRUE");
311-
}
337+
this.notEmpty = Boolean.valueOf(properties.getProperty("notEmpty"));
338+
this.enableMethodAnnotation = Boolean.valueOf(properties.getProperty("enableMethodAnnotation"));
339+
this.checkExampleEntityClass = Boolean.valueOf(properties.getProperty("checkExampleEntityClass"));
340+
//默认值 true,所以要特殊判断
312341
String useSimpleTypeStr = properties.getProperty("useSimpleType");
313342
if (StringUtil.isNotEmpty(useSimpleTypeStr)) {
314-
this.useSimpleType = useSimpleTypeStr.equalsIgnoreCase("TRUE");
315-
}
316-
String enumAsSimpleTypeStr = properties.getProperty("enumAsSimpleType");
317-
if (StringUtil.isNotEmpty(enumAsSimpleTypeStr)) {
318-
this.enumAsSimpleType = enumAsSimpleTypeStr.equalsIgnoreCase("TRUE");
343+
this.useSimpleType = Boolean.valueOf(useSimpleTypeStr);
319344
}
345+
this.enumAsSimpleType = Boolean.valueOf(properties.getProperty("enumAsSimpleType"));
320346
//注册新的基本类型,以逗号隔开,使用全限定类名
321347
String simpleTypes = properties.getProperty("simpleTypes");
322348
if (StringUtil.isNotEmpty(simpleTypes)) {

src/main/java/tk/mybatis/mapper/mapperhelper/MapperHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ public Config getConfig() {
273273
*/
274274
public void setConfig(Config config) {
275275
this.config = config;
276+
if(config.getMappers() != null && config.getMappers().size() > 0){
277+
for (Class mapperClass : config.getMappers()) {
278+
registerMapper(mapperClass);
279+
}
280+
}
276281
}
277282

278283
/**

wiki/Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 更新日志
22

3+
## 3.5.3 - 2018-03-06
4+
5+
- 解决 MapperHelper.setConfig 方法中没有处理 mappers 的 BUG,主要影响 starter 中的使用。
6+
37
## 3.5.2 - 2018-01-24
48

59
#### 1. `delete``deleteByPrimaryKey` 增加对乐观锁注解 `@Version` 的支持。

0 commit comments

Comments
 (0)
0