说明
使用spring data jpa的deleteAll功能,报错
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
从控制台的打印看
delete
from
sms_code_record
where
id = ?
and version = ?
这条sql是有问题的,具体原因还没有查明
解决
手写HQL
@Transactional
@Modifying
@Query("delete from SmsCodeEntity e where e.id in (:ids)")
int deleteAllByIdIn(@Param("ids") List<Integer> ids);
网友评论