I've seen several answers to this but none of them are fixing my problem.
I'm not even trying to delete, but I set a status to -1 and elsewhere in the app the object filtered on its status so that must be the delete.
I'm trying to set the user.status to -1
user.setType(-1);
userService.updateUser(user);
User has this in its class
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "user_id", updatable = false)
@LazyCollection(LazyCollectionOption.FALSE)
private List<UserGroupMembership> groupMemberships = new ArrayList<UserGroupMembership>();
This is in UserGroupMembership
@ManyToOne(fetch = FetchType.LAZY)
@Fetch(value = FetchMode.JOIN)
@JoinColumn(name = "user_id", insertable = false, updatable = false)
@LazyCollection(LazyCollectionOption.FALSE)
private UserPreview user;
Error is
deleted object would be re-saved by cascade (remove deleted object from associations): [server.model.dao.entities.UserGroupMembership#22]; nested exception is
org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations):
Can anyone help?