title: Spring Boot extending CrudRepository
body: <p>I'm using Hibernate in a Spring Boot app. I'm making a new CrudRepository for all my Model objects, to do basic CRUD tasks. They look like this:</p>
  
  <pre><code>@Repository
  public interface FoobarCrudRepo extends CrudRepository&lt;Foobar, Long&gt; {
  }
  </code></pre>
  
  <p>But then I always need to do some additional things, like custom search queries with inequalities and such. I follow a pattern like this:</p>
  
  <pre><code>@Repository
  public class FoobarDao {
  
      @PersistenceContext
      EntityManager em;
  
      public List&lt;Foobar&gt; findFoobarsByDate(Date date) {
          String sql = "select fb from Foobar fb where createdDate &gt; :date";
          ...
          return query.getResultList();
      }
  }
  </code></pre>
  
  <p>My question is, can I combine these two concepts into a single class? I tried making it an abstract class, like so:</p>
  
  <pre><code>@Repository
  public abstract class FoobarCrudRepo extends CrudRepository&lt;Foobar, Long&gt; {
  
      @PersistenceContext
      EntityManager em;
  
      public List&lt;Foobar&gt; findFoobarsByDate(Date date) {
          String sql = "select fb from Foobar fb where createdDate &gt; :date";
          ...
          return query.getResultList();
      }
  
  }
  </code></pre>
  
  <p>But then Spring didn't create a bean for it.</p>
  
  <p>How can I accomplish this?</p>
  
  <p>Thanks!</p>