1

I've seen several answers to this but none of them are fixing my problem.

org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations):

org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade : Error while trying to delete a Patient object

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?

beek
  • 3,522
  • 8
  • 33
  • 86

1 Answers1

0

The entity I was updating had some missing attributes which was what was being deleted, I reconnected those by refetching the entity and it was fine.

beek
  • 3,522
  • 8
  • 33
  • 86