Open helloworldtang opened 7 years ago
测试看了,没有发现问题。 测试如下:
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Country country = new Country();
country.setId(174);
country.setCountryname(null);
Assert.assertEquals(1, mapper.updateByPrimaryKey(country));
日志如下:
DEBUG [main] - ==> Preparing: UPDATE country SET countryname = ?,countrycode = ? WHERE id = ?
DEBUG [main] - ==> Parameters: null, null, 174(Integer)
DEBUG [main] - <== Updates: 1
是不是有些配置会导致Null会被过虑掉呢?
我这边还是有这个报错
很多接口就是根据字段是否为null来选择是否去做更新的,你换其他方法试试
@workcheng 如果把gpsUrl字段赋值的话,sql就正常了。 这里面用的是通用mapper的方法,没有自己写的
CarTtDO
代码发出来看看。
下面的代码在执行时,发现生成的sql与预期的不一样。预期是 UPDATE car_tt set name=? WHERE id = ?