title: JpaRepository caches newly created object. How to refresh it?
body: <p>I have a JpaRepository persisting newly created entity in Spring MVC app. This entity looks like this (very simplified):</p>
  
  <pre><code>@Entity
  public class Translation {
  
      .....
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private long id;
  
      @ManyToOne(fetch = FetchType.LAZY)
      private Version version;
  
      ....
  
  }
  </code></pre>
  
  <p>and Version entity:</p>
  
  <pre><code>@Entity
  public class Version {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "id")
      private long id;
  
      @Column(name = "name")
      private String name;
  
      @Column(name = "version_code")
      private long code;
  
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "version", cascade = {CascadeType.ALL}, orphanRemoval = true)
      private Set&lt;Translation&gt; translations;
  
  }
  </code></pre>
  
  <p>I create a translation object like this </p>
  
  <pre><code>            TranslationDTO t = new TranslationDTO();
              t.setText(translationText);
              ClientVersionDTO version = new ClientVersionDTO();
              version.setId(11);
              t.setVersion(version);
  </code></pre>
  
  <p>where 11 is a version that exists in the database already from the very beginning. Please notice that I do not set values for <code>name</code> and <code>code</code> of ClientVersionDTO. </p>
  
  <p>Then I have a service that persists new object (I use <code>dozer</code> library to convert DTO to entities)</p>
  
  <pre><code>@Service
  @Transactional
  public class TranslationsServiceImpl implements TranslationsService {
      @Override
      public Long create(TranslationDTO translationDTO) {
          Translation translation = translationsConverter.unconvert(translationDTO);
          Translation t = translationRepository.saveAndFlush(translation);
  
          Translation t2 = translationRepository.findOne(t.getId());
  
          // !!!! t2.getVersion() returns version where no values are set to 'code' and 'name'
  
          return t2.getId();
      }
  }
  </code></pre>
  
  <p>Please notice my comment "t2.getVersion() returns version where no values are set to 'code' and 'name'" - I was expecting so that when I fetch the data from the database, I would get a <code>Version</code> object right from the database with <code>code</code> and <code>name</code> values set. However they are not set. So basically what I get as a <code>t2.getVersion()</code> object is the same object as in input argument <code>translationDTO.getVersion()</code>.  How can they I re-invalidate the <code>Version</code> object?</p>
  
  <p><em>UPDATE</em> tried moving @Transactional to JpaRepository, but still the same result.</p>