Mapper
Mapper copied to clipboard
Example对象new时为啥notnull是false,其他框架都是true
这种默认值不能从框架直接修改,影响范围太大,可以考虑自己封装一个newExample的方法,自己调用赋值true。如果你有更好的方法,可以继续沟通或者PR。
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
if (notNull) {
throw new MapperException("Value for " + property + " cannot be null");
} else {
return;
}
}
if (property == null) {
return;
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
if (notNull) {
throw new MapperException("Between values for " + property + " cannot be null");
} else {
return;
}
}
if (property == null) {
return;
}
criteria.add(new Criterion(condition, value1, value2));
}
现在看到这种null的时候我还在想,要不要直接转换为 column is null。
这些做法都太隐式了,报错才是最对的。历史问题是不是可以提供一个新的StrictExample类
增加一个配置项,可以配一下 不配置默认走老逻辑 这样可以兼顾老用户