I think this is what happened in your flow:
- Hibernate loads the User from the database, which has a UserRole with id = 2ee569d5-91dc-4eb9-82f7-7ce7d76b158a.
- A new UserDto is sent, containing a UserRole with id = 150179b8-a235-452f-aaeb-a536174a0f94.
- modelMapper.map(userDto, user) overwrites the entire UserRole object in User, replacing it with a new instance from UserDto.
- Hibernate detects that the UserRole associated with User has changed from the old id to a new id, but the identifier of a managed entity cannot be changed → Hibernate throws an error: