based on this article https://thorben-janssen.com/spring-data-jpa-save-saveandflush-and-saveall/ I understand that calling a save for a managed entity is waste or resources and not actually required, and I tried this in my local and it works as expected. e.g:
@Override
@Transactional
public UserEntity update(User user){
UserEntity e = userRepo.findById(user.getId());
e.setName("test");
return e;
}
without calling the save
method the update query is called.
but when I call it from an inner method ,i.e
@Override
public UserEntity update(User user){
return performUpdate(user);
}
@Transactional
public UserEntity performUpdate(User user){
UserEntity e = userRepo.findById(user.getId());
e.setName("test");
return e;
}
Now for some reason the update query is not being called at all, can someone explain me why this is happening and how can I fix this?