title: What is the difference between an Spring Entity Manager and Spring Data Repository?
body: <p>I am using JPA in a website. After exploring about options for saving data, I found 2 approach. The first approach is using an implementation of javax.persistence.EntityManager. I used LocalContainerEntityManagerFactoryBean to instantiate an instance of EntityManager. Once I obtain an instance of an EntityManager, I can use it to save an entity. For example,</p>
  
  <pre><code>entityManager.merge(someEntity);
  </code></pre>
  
  <p>Another option is to use an instance of org.springframework.data.repository.CrudRepository. One, I obtain an instance of a CrudRepository, I can use it to save an entity. For example,</p>
  
  <pre><code>aCrudRepository.save(someEntity);
  </code></pre>
  
  <p>What is the difference between using an EntityManager and a CrudRepository to persist an entity into a database ? What are the benefit or disadvantage of the two approach (entity manager vs. crud repository) ?</p>