Sring data and Hibernate, how to avoid child (non-owning side) entity deletion by Hibernate (without cascade)?

No, in Spring Data Rest, i’m talking about @RepositoryRestResource like:

@RepositoryRestResource
public interface UserRepository extends JpaAuditRepository<User, Long> {}

Call those generated endpoints and PATCH will do partial updates - your version is the manual Spring MVC approach.

@see:


If you want to do your manual mvc version, it looks more like:

 @PatchMapping(path="/user/{id}")
     public User updateUser(@RequestBody User body){
         User user = userService.getUser(body.getId());
         
         //you'd do manual updates like this:
         user.setField(body.getField());

         //But i'm guessing you'd need to change the way the update works in your service here: 
         return userService.updateUser(user);
     }