一、Mybatis-Plus 修改语法错误
1、错误截图:
2、原因:条件构建错误。
在 MyBatis-Plus 中,Mapper 的 update() 方法通常有两种常见的重载形式:
-
update(@Param("et") T entity, @Param("ew") UpdateWrapper<T> updateWrapper):这种形式需要两个参数:一个是实体对象
entity,另一个是条件构造器updateWrapper。注意:这里
setEntity()方法的作用是将实体类中的非null字段提取出来作为更新内容,但它需要与update()方法的第一个参数(实体对象)配合使用。 -
update(UpdateWrapper<T> updateWrapper):这种形式只接受一个参数,即条件构造器
updateWrapper。注意:在这种情况下,
updateWrapper必须通过set()方法明确指定更新的字段,而不能使用setEntity()。
3、修正如下: