import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import java.util.List;
// 假设有一个Mapper接口
public interface YourEntityMapper extends BaseMapper<YourEntity> {
// ...
}
// 实现类中使用
@Service
public class YourService {
@Autowired
private YourDao yourEntityMapper;
public void modifyWithInCondition(List<Integer> ids) {
// 创建UpdateWrapper
UpdateWrapper<YourEntity> updateWrapper = new UpdateWrapper<>();
// 设置IN条件
updateWrapper.in("column_name", ids);
// 设置其他修改条件
YourEntity yourEntity = new YourEntity();
yourEntity.setTitle("修改的内容");
// 执行修改操作
yourDao.update(yourEntity,updateWrapper);
}
坑1.修改多个id的值,用in条件(MybatisPlus)
于 2024-07-07 16:45:38 首次发布