onetomany 联级删除

1、@OneToMany(mappedBy = "userModel", cascade = CascadeType.ALL, fetch = FetchType.EAGER,orphanRemoval=true)
private Set<UserVessel> vessels;
把orphanRemoval=true加上
2、userModel.getVessels().clear 清空set 集合

3、userModelDao.saveOrUpdate(userModel);

你可能感兴趣的:(net)