This is a curiosity question based on the fact that in Java everything is passed by value. The signature of the save method is:
<S extends T> S save(S entity);
Say I have this code :
MyEntity entity = new MyEntity();
entity.setId(null);
entity.setName("entity");
MyEntity savedEntity = repository.save(entity);
When calling repository.save(entity), isn't entity updated in the save method? I mean at the end of save execution, savedEntity and entity have the same state, so why returning it ?
Thanks for your clarification.