该错误是一个事务没有提交,而另一个事务开始。在循环插入或者更新数据的时候,使用多线程,但是没有保证线程安全的情况下回出现该问题。
<update id="updateByFileOcsIdSn">
update file_ocs_info SET assessment_sn=#{assessmentSn} where file_ocs_id=#{fileOcsId}
</update>
if (selfEvaluationApplicationFiles != null && selfEvaluationApplicationFiles.size() > 0) {
String finalSn1 = sn;
selfEvaluationApplicationFiles.parallelStream().forEach(self -> {
//获取fileocsId
String ocsId = self.getFileOcsId();
//根据ocsId插入架构师编号
fileOcsInfoMapper.updateByFileOcsIdSn(finalSn1, ocsId);
});
}
这里修改parallelStream为stream就可以