使用mybatis删除时,sql成功执行,没有事务,无异常,数据却没有删除
先看下日志
2020-09-02 15:55:04.687 DEBUG[http-nio-8081-exec-5]f.w.i.d.Y.deleteById.debug():143 -==> Preparing: delete from task where id = ?
2020-09-02 15:55:04.687 DEBUG[http-nio-8081-exec-5]f.w.i.d.Y.deleteById.debug():143 -==> Parameters: "1-1-1"(String)
2020-09-02 15:55:04.742 DEBUG[http-nio-8081-exec-5]f.w.i.d.Y.deleteById.debug():143 -<== Updates: 0
sql也执行了,但是update 了0行,数据没有删除,直接用工具执行sql没问题,一脸懵。。。
而且通过id update数据库中的值也能修改成功,看下日志
2020-09-02 15:59:47.522 DEBUG[http-nio-8081-exec-1]f.w.i.d.Y.updateByPrimaryKey.debug():143 -==> Preparing: UPDATE task SET name = ? WHERE id = ?
2020-09-02 15:59:47.525 DEBUG[http-nio-8081-exec-1]f.w.i.d.Y.updateByPrimaryKey.debug():143 -==> Parameters: 任务2---2(String), 1-1-1(String)
2020-09-02 15:59:47.562 DEBUG[http-nio-8081-exec-1]f.w.i.d.Y.updateByPrimaryKey.debug():143 -<== Updates: 1
比对日志,终于发现是参数的问题,一个是"1-1-1"(String),一个是1-1-1(String),删除时多了两个 ",是我前台多转换了一次,导致参数出了问题