数据库的事务
Less than 1 minute
@Query(
value = "update baby_resource set deleted_at = 0 where id in ?1",
nativeQuery = true
)
@Modifying
void realDelete(List<Long> ids);
然后在使用如下
public void realDelete(List<Long> ids) {
babyResourceRepository.realDelete(ids);
}
上述会有以下的错误:
Executing an update/delete query] with root cause
需要在realDelete
方法上面加上@Transactional
@Transactional
public void realDelete(List<Long> ids) {
babyResourceRepository.realDelete(ids);
}