Skip to content

Commit 570ef15

Browse files
DiligentNezhaabel533
authored andcommitted
修复 Example.Criteria 未设置 where 条件查询时,带有逻辑删除注解的表报错问题,fixed #722
1 parent b08258b commit 570ef15

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

core/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,6 @@ public static String exampleCheck(Class<?> entityClass) {
944944
public static String exampleWhereClause() {
945945
return "<if test=\"_parameter != null\">" +
946946
"<where>\n" +
947-
" ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(_parameter)}" +
948947
" <trim prefix=\"(\" prefixOverrides=\"and |or \" suffix=\")\">\n" +
949948
" <foreach collection=\"oredCriteria\" item=\"criteria\">\n" +
950949
" <if test=\"criteria.valid\">\n" +
@@ -973,6 +972,7 @@ public static String exampleWhereClause() {
973972
" </if>\n" +
974973
" </foreach>\n" +
975974
" </trim>\n" +
975+
" ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(_parameter)}" +
976976
"</where>" +
977977
"</if>";
978978
}
@@ -984,7 +984,6 @@ public static String exampleWhereClause() {
984984
*/
985985
public static String updateByExampleWhereClause() {
986986
return "<where>\n" +
987-
" ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(example)}" +
988987
" <trim prefix=\"(\" prefixOverrides=\"and |or \" suffix=\")\">\n" +
989988
" <foreach collection=\"example.oredCriteria\" item=\"criteria\">\n" +
990989
" <if test=\"criteria.valid\">\n" +
@@ -1013,6 +1012,7 @@ public static String updateByExampleWhereClause() {
10131012
" </if>\n" +
10141013
" </foreach>\n" +
10151014
" </trim>\n" +
1015+
" ${@tk.mybatis.mapper.util.OGNL@andNotLogicDelete(example)}" +
10161016
"</where>";
10171017
}
10181018

core/src/main/java/tk/mybatis/mapper/util/OGNL.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,7 @@ public static String andNotLogicDelete(Object parameter) {
243243
EntityColumn column = entry.getValue();
244244
if (column.getEntityField().isAnnotationPresent(LogicDelete.class)) {
245245
// 未逻辑删除的条件
246-
result = column.getColumn() + " = " + SqlHelper.getLogicDeletedValue(column, false);
247-
248-
// 如果Example中有条件,则拼接" and ",
249-
// 如果是空的oredCriteria,则where中只有逻辑删除注解的未删除条件
250-
if (example.getOredCriteria() != null && example.getOredCriteria().size() != 0) {
251-
result += " and ";
252-
}
246+
result = "and " + column.getColumn() + " = " + SqlHelper.getLogicDeletedValue(column, false);
253247
}
254248
}
255249
}

0 commit comments

Comments
 (0)