title: Spring data JPA repositories not saving to database
body: <p>I'm trying to initialise spring-data repositories without using the <code>@EnableJpaRepositories</code> annotation and spring autowiring. In my existing application I have access to a <code>DataSource</code> object that I want to use for DB communication. The following code generates an implementation for <code>TravelAlertRepository</code> and reads existing rows in the DB. However, whenever I try to update these changes are not shown in the DB. I am also not able to create new rows in the DB. </p>
  
  <pre><code>interface TravelAlertRepository extends 
      org.springframework.data.repository.CrudRepository&lt;TravelAlertVO, Long&gt;{}
  
  class SpringDataRepositories {
  
  private TravelAlertRepository travelAlertRepository;
  private javax.persistence.EntityManager entityManager;
  
  SpringDataRepositories() {
  
    this.entityManager = createEntityManager();
    RepositoryFactorySupport factory = new JpaRepositoryFactory(entityManager);
    travelAlertRepository = factory.getRepository(TravelAlertRepository.class);
  }
  
  private static javax.persistence.EntityManager createEntityManager() {
  
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPersistenceProviderClass(HibernatePersistenceProvider.class);
    em.setJpaProperties(hibProperties());
    em.setPersistenceUnitName("persistentName");
    em.setPackagesToScan(
      TravelAlertVO.class.getPackage().getName()
    );
    em.afterPropertiesSet();
    return em.getObject().createEntityManager();
  }
  
  private static Properties hibProperties() {
  
    Properties properties = new Properties();
    properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
    properties.put("hibernate.show_sql", true);
    return properties;
  }
  
  public static DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
  
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl("jdbc:mysql://localhost:3306/mydb");
    dataSource.setUsername("mydb");
    dataSource.setPassword("mydb");
  
    return dataSource;
  }
  }
  </code></pre>
  
  <p>Any help appreciated.</p>