title: How to force hibernate not update all entities with same id?
body: <p>When I save the <code>newAddress</code> using <code>JpaRepository&lt;Address, AddressID&gt;</code> save method it updates all references of the method scope, including <code>oldRegistration</code>.</p>
  
  <p>Since I wanna execute other actions with the <code>oldRegistration</code> data after the <code>newAddress</code> is saved It is giving me an unexpected behavior. </p>
  
  <pre><code>    Registration registerAddress(String cpf, MultipartFile file) throws IOException {
  
          Registration oldRegistration = registrationService.findById(new CPF(cpf)).orElseThrow(RegistrationNotFound::new);
          Address oldAddress = addressService.findById(oldRegistration.getAddressId()).orElseThrow(AddressNotFoundException::new);
  
          StorageFile newStorageFile = storageFileService.saveImage(file.getOriginalFilename(), file.getInputStream(), file.getSize());
  
          Address newAddress = oldAddress.setStorageFile(newStorageFile.getId());
          Registration newRegistration = oldRegistration.registerAddressFile(newAddress.getId());
  
          addressService.save(newAddress);
          Registration savedRegistration = registrationService.save(newRegistration);
  
          storageFileService.findById(oldAddress.getStorageFileId()).ifPresent(storageFile -&gt; {
              storageFileService.delete(storageFile);
              storageFileService.removeFromStorageAsync(storageFile);
          });
  
          return savedRegistration;
      }
  </code></pre>
  
  <p>I'm expecting the <code>oldAddress</code> keep all its data. </p>
  
  <p>After <code>addressService.save(newAddress);</code> all data from <code>oldAddress</code> is setted as the same of the <code>newAddress</code>.</p>
  
  <p>How to tell Spring does not update every reference that has the same id?</p>