我有这个班级
public class User implements Serializable {
@ManyToMany(cascade = {CascadeType.ALL} )
@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
private Collection<Role> rolesCollection = new ArrayList<>();
}
}
我正在使用此代码删除
User user = userAPI.findUser(userName);
user = userDao.merge(user);
try {
userDao.delete(user);
} catch (Exception e) {
e.printStackTrace();
}
但我仍然拥有数据库中的数据,我没有任何例外。
我想删除在连接表中具有角色的用户......我该怎么做?