Skip to content

Commit 72d0c36

Browse files
committed
针对 mybatis-provider 中 @Entity.Prop 注解的兼容性改动
1 parent 8d6d219 commit 72d0c36

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

mapper/src/main/java/io/mybatis/mapper/example/ExampleProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public static String deleteByExample(ProviderContext providerContext) {
135135
+ "DELETE FROM " + entity.tableName()
136136
+ util.parameterNotNull("Example cannot be null")
137137
//是否允许空条件,默认允许,允许时不检查查询条件
138-
+ (entity.getProp("deleteByExample.allowEmpty", true) ?
138+
+ (entity.getPropBoolean("deleteByExample.allowEmpty", true) ?
139139
"" : util.variableIsFalse("_parameter.isEmpty()", "Example Criteria cannot be empty"))
140140
+ EXAMPLE_WHERE_CLAUSE
141141
+ util.ifTest("endSql != null and endSql != ''", () -> "${endSql}"));
@@ -158,7 +158,7 @@ public String getSql(EntityTable entity) {
158158
//TODO 测试
159159
+ variableNotNull("example", "Example cannot be null")
160160
//是否允许空条件,默认允许,允许时不检查查询条件
161-
+ (entity.getProp("updateByExample.allowEmpty", true) ?
161+
+ (entity.getPropBoolean("updateByExample.allowEmpty", true) ?
162162
"" : variableIsFalse("example.isEmpty()", "Example Criteria cannot be empty"))
163163
+ UPDATE_BY_EXAMPLE_WHERE_CLAUSE
164164
+ ifTest("example.endSql != null and example.endSql != ''", () -> "${example.endSql}");
@@ -182,7 +182,7 @@ public String getSql(EntityTable entity) {
182182
+ EXAMPLE_SET_CLAUSE_INNER_WHEN
183183
+ variableNotNull("example", "Example cannot be null")
184184
//是否允许空条件,默认允许,允许时不检查查询条件
185-
+ (entity.getProp("updateByExample.allowEmpty", true) ?
185+
+ (entity.getPropBoolean("updateByExample.allowEmpty", true) ?
186186
"" : variableIsFalse("example.isEmpty()", "Example Criteria cannot be empty"))
187187
+ UPDATE_BY_EXAMPLE_WHERE_CLAUSE
188188
+ ifTest("example.endSql != null and example.endSql != ''", () -> "${example.endSql}");
@@ -208,7 +208,7 @@ public String getSql(EntityTable entity) {
208208
//TODO 测试
209209
+ variableNotNull("example", "Example cannot be null")
210210
//是否允许空条件,默认允许,允许时不检查查询条件
211-
+ (entity.getProp("updateByExampleSelective.allowEmpty", true) ?
211+
+ (entity.getPropBoolean("updateByExampleSelective.allowEmpty", true) ?
212212
"" : variableIsFalse("example.isEmpty()", "Example Criteria cannot be empty"))
213213
+ UPDATE_BY_EXAMPLE_WHERE_CLAUSE
214214
+ ifTest("example.endSql != null and example.endSql != ''", () -> "${example.endSql}");

mapper/src/test/java/io/mybatis/mapper/model/User.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
import io.mybatis.provider.Entity;
2020

2121
@Entity.Table(value = "user",
22-
props = {
23-
@Entity.Prop(name = "deleteByExample.allowEmpty", value = "false", type = Boolean.class),
24-
@Entity.Prop(name = "updateByExample.allowEmpty", value = "false", type = Boolean.class),
25-
@Entity.Prop(name = "updateByExampleSelective.allowEmpty", value = "false", type = Boolean.class)
26-
}
22+
props = {
23+
@Entity.Prop(name = "deleteByExample.allowEmpty", value = "false"),
24+
@Entity.Prop(name = "updateByExample.allowEmpty", value = "false"),
25+
@Entity.Prop(name = "updateByExampleSelective.allowEmpty", value = "false")
26+
}
2727
)
2828
public class User {
2929
@Entity.Column(id = true)
@@ -60,9 +60,9 @@ public void setSex(String sex) {
6060
@Override
6161
public String toString() {
6262
return "User{" +
63-
"id=" + id +
64-
", name='" + userName + '\'' +
65-
", sex='" + sex + '\'' +
66-
'}';
63+
"id=" + id +
64+
", name='" + userName + '\'' +
65+
", sex='" + sex + '\'' +
66+
'}';
6767
}
6868
}

0 commit comments

Comments
 (0)