fix SQLProvider.updateSelective update empty
This commit is contained in:
@ -278,7 +278,7 @@ public class SQLProvider {
|
||||
}
|
||||
String setClause = meta.fieldColumnList.stream()
|
||||
.filter(FieldColumn::isNotId)
|
||||
.filter(fc -> fc.isNotEmpty(entity))
|
||||
.filter(fc -> fc.isNotNull(entity))
|
||||
.map(fc -> "`%s` = #{%s}".formatted(fc.columnName, fc.fieldName))
|
||||
.collect(Collectors.joining(", "));
|
||||
return "UPDATE `%s` SET %s WHERE `%s` = #{%s}".formatted(meta.table, setClause, meta.idFieldColumn.columnName, meta.idFieldColumn.fieldName);
|
||||
@ -551,6 +551,18 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNull(Object entity) {
|
||||
try {
|
||||
return Ref.getFieldValue(entity, field, Object.class) == null;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNotNull(Object entity) {
|
||||
return !isNull(entity);
|
||||
}
|
||||
|
||||
public boolean isEmpty(Object entity) {
|
||||
try {
|
||||
return TimiJava.isEmpty(Ref.getFieldValue(entity, field, Object.class));
|
||||
|
||||
Reference in New Issue
Block a user