title: CrudRepository save method not returning updated entity
body: <p>I'm working with Spring and in it <code>spring-data-jpa:1.7.0.RELEASE</code> and <code>hibernate-jpa-2.1-api:1.0.0.Final</code>. My database is a MySQL. In a integration test, when I save an entity, the <code>entityRepository.save()</code> method does not return a update version of it (with the auto-incremented id populated for example), thus I can see it is in the database.</p>
  
  <p>Here's my configuration class:</p>
  
  <pre><code>//@EnableTransactionManagement
  @EnableJpaRepositories(basePackages = "core.repository")
  @Configuration
  @PropertySource("classpath:application.properties")
  public class JPAConfiguration {
  
      @Autowired
      private Environment env;
  
      private
      @Value("${db.driverClassName}")
      String driverClassName;
      private
      @Value("${db.url}")
      String url;
      private
      @Value("${db.username}")
      String user;
      private
      @Value("${db.password}")
      String password;
  
      @Bean
      public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
          return new PropertySourcesPlaceholderConfigurer();
  
      }
  
      @Bean
      public DataSource dataSource() {
  
          DriverManagerDataSource dataSource = new DriverManagerDataSource();
  
          dataSource.setDriverClassName(driverClassName);
          dataSource.setUrl(url);
          dataSource.setUsername(user);
          dataSource.setPassword(password);
          return dataSource;
      }
  
      @Bean
      public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  
          HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
          vendorAdapter.setGenerateDdl(true);
          vendorAdapter.setDatabasePlatform(env.getProperty("hibernate.dialect"));
  
          final LocalContainerEntityManagerFactoryBean em =
                  new LocalContainerEntityManagerFactoryBean();
  
          em.setJpaVendorAdapter(vendorAdapter);
          em.setPackagesToScan(new String[]{"core.persistence"});
          em.setDataSource(dataSource());
          em.afterPropertiesSet();
  
  
          return em;
      }
  
      @Bean
      public EntityManager entityManager(EntityManagerFactory entityManagerFactory) {
          return entityManagerFactory.createEntityManager();
      }
  
      @Bean
      public JpaTransactionManager transactionManager(final EntityManagerFactory emf) {
          final JpaTransactionManager transactionManager = new JpaTransactionManager();
          transactionManager.setEntityManagerFactory(emf);
          return transactionManager;
      }
  
      @Bean
      public HibernateExceptionTranslator hibernateExceptionTranslator() {
          return new HibernateExceptionTranslator();
      }
  }
  </code></pre>
  
  <p>Here's my test class:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = {JPAConfiguration.class})
  //@Transactional
  //@TransactionConfiguration(defaultRollback = true)
  public class AgencyRepositoryIntegrationTests {
  
      @Autowired
      AgencyRepository agencyRepository;
  
      @Test
      public void testThatAgencyIsSavedIntoRepoWorks() throws Exception {
  
          Agency c = DomainTestData.getAgency();
          Agency d = agencyRepository.save(c);
          // here d equals to c but both have id 0.
  
          Collection&lt;Agency&gt; results = Lists.newArrayList(agencyRepository.findAll());
          //here results != null and it does contain the agency object.
          assertNotNull(results);
      }
  }
  </code></pre>
  
  <p>I end up commenting the Transactional annotations (both in the test and in the configuration class) due to research other questions in stackoverflow, but it did not work.</p>
  
  <p>Thanks</p>