title: Difference between Repository and Service layer
body: <p>I looked through some related questions but still I don't see much difference between the a repository and a service layer. So given the example I suppose it should look like this , if not please tell me why?</p>
  
  <pre><code>public interface ProductRepository extends CrudRepository&lt;Product, Long&gt;{
  
      public List&lt;Product&gt; findByName(String name);
      public List&lt;Product&gt; findByPrice(Double price);
  }
  
  public interface ProductService {
  
      public List&lt;Product&gt; findAll();
      public Product findById(Long id);
      public Product save(Product product);
      public void delete(Product product);
      public List&lt;Product&gt; findByName(String name);
      public List&lt;Product&gt; findByPrice(Double price);
  }
  </code></pre>
  
  <p>and the implementation of the ProductService would use the ProductRepository to implement the methods. As I understand from <a href="http://docs.spring.io/spring-data/jpa/docs/1.3.0.RELEASE/reference/html/jpa.repositories.html" rel="noreferrer">http://docs.spring.io/spring-data/jpa/docs/1.3.0.RELEASE/reference/html/jpa.repositories.html</a> the queries for methods from the repository are auto generated. In my example the methods are repeated in the repository and Service, so please explain what/why needs to be changed?</p>