当前使用版本(必填,否则不予处理)
3.4.2/3.5.1
该问题是如何引起的?(确定最新版也有问题再提!!!)
public static
重现步骤(如果有就写完整)
实体 package cn.hs.entity;
import cn.hs.enums.NewsEnum; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors;
import java.io.Serializable; import java.util.Date;
/*
*
* 新闻动态
*
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 标题
*/
private String title;
/**
* 正文
*/
private String content;
/**
* 简介
*/
private String synopsis;
/**
* 封面图
*/
private Long cover;
/**
* 作者
*/
private String author;
/**
* 是否置顶轮播
*/
private Integer isTop;
/**
* 类型
*/
private NewsEnum type;
/**
* 外链
*/
private String outerLink;
/**
* 阅读量
*/
private Integer viewCount;
/**
* 操作者
*/
private String operator;
/**
* 版本
*/
@Version
private Integer version;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* 删除标志位
*/
@TableLogic
private Integer deleted;
}
方法 @Override public ResultDTO updateNotice(Long id, NewsCenterVO newsCenterVO) { NewsCenter newsCenter = this.getById(id); //Integer version = newsCenter.getVersion();
//存正文
newsCenter = JSON.parseObject(JSON.toJSONString(newsCenterVO), NewsCenter.class);
newsCenter.setType(NewsEnum.notice);
//newsCenter.setVersion(version);
this.updateById(newsCenter);
return ResultDTO.success();
}
执行update时log为 Creating a new SqlSession SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@612c180e] was not registered for synchronization because synchronization is not active JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@1dc06dde] will not be managed by Spring ==> Preparing: UPDATE news_center_info SET title=?, content=?, author=?, type=?, update_time=? WHERE id=? AND deleted=0 ==> Parameters: 文章标题1(String), 正文2(String), 3333(String), 2(Integer), 2022-05-11 09:45:16.997(Timestamp), 26(Long) <== Updates: 1 Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@612c180e]
报错信息
无报错信息,乐观锁失效。
Comment From: miemieYaho
??? 你这不是都知道因果了?
Comment From: SQNDNT
??? 你这不是都知道因果了? 更新不加版本这玩意没问题?
Comment From: miemieYaho
你要mp凭空给你变个版本号出来吗?