背景
@Override @Transactional public RetResult update(SysUserTable sysUserTable) { if (null != sysUserTable) { //删除关联 List<SuperSuPro> superSuPros = superSuProRepository.findByUserUid(userUid); List<String> supersuUids = new LinkedList<>(); superSuPros.forEach(superSuPro -> { String supersuUid = superSuPro.getSupersuUid(); supersuUids.add(supersuUid); }); superSuProRepository.deleteBySupersuUidIn(supersuUids); //增加关联 farmCodes.forEach(farmCode->{ SuperSuPro superSuPro = new SuperSuPro(); superSuPro.setSuperRandomUUID(); superSuPro.setUserUid(userUid); superSuPro.setFarmCode(farmCode); superSuProRepository.save(superSuPro); }); return ResultUtil.success("修改成功"); } return ResultUtil.error(-1, "修改失败,请联系管理员"); }
No EntityManager with actual transaction available for current thread - cannot reliably process ‘remove‘ call
原因
@Repository public interface SuperSuProRepository extends BaseRepository<SuperSuPro> { void deleteBySupersuUidIn(List<String> supersuUids); }
解决办法
@Repository public interface SuperSuProRepository extends BaseRepository<SuperSuPro> { @Modifying void deleteBySupersuUidIn(List<String> supersuUids); }
原文:https://www.cnblogs.com/zuiyue_jing/p/14653216.html