title: Clashes between count() methods - CrudRepository - Spring
body: <p>I prefer to warn you, my english is not perfect but I'll try to do my best.</p>
  
  <p>I'm actually in an internship and my task is to create a webservice. Before this, I'm supposed to work with Maven and create repositories, models and others.</p>
  
  <p>For now, I've got a problem with the repository of a simple Java class.</p>
  
  <p><strong>Here is my class :</strong></p>
  
  <pre><code>package com.XXX;
  
  import lombok.Data;
  import lombok.NoArgsConstructor;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import java.sql.Timestamp;
  
  @Entity
  //Generate getters and setters
  @Data
  //Generate a constructor with to arguments
  @NoArgsConstructor
  public class Day_ {
      @Id
      private int day_id_Date;
      private Timestamp day_Date;
  
      public Day_(int day_id_Date, Timestamp day_Date) {
          this.day_id_Date = day_id_Date;
          this.day_Date = day_Date;
      }
  }
  </code></pre>
  
  <p>Pretty simple as I said.</p>
  
  <p><strong>Now here comes my repository :</strong></p>
  
  <pre><code>package com.XXX;
  
  import com.XXX.Day_;
  import org.springframework.data.repository.CrudRepository;
  
  public interface DayRepository extends CrudRepository&lt;Day_, Long&gt; {
  }
  </code></pre>
  
  <p>I've actually took this from an example on internet. Works fine for him but not for me. I'm getting the following error :</p>
  
  <pre><code>    Error:(6, 8) java: types org.springframework.data.repository.Repository&lt;com.atos.test.account.tables.Day_,java.lang.Long&gt; and org.springframework.data.repository.CrudRepository&lt;com.atos.test.account.tables.Day_,java.lang.Long&gt; are incompatible; both define count(), but with unrelated return types
  </code></pre>
  
  <p>Now I've tried to override the <code>count()</code> method by doing :</p>
  
  <pre><code>package com.XXX;
  
  import com.XXX.Day_;
  import org.springframework.data.repository.CrudRepository;
  
  public interface DayRepository extends CrudRepository&lt;Day_, Long&gt; {
      @Override
      long count();
  }
  </code></pre>
  
  <p>But I get the following error (which is almost the same) :</p>
  
  <pre><code>    Error:(6, 8) java: types org.springframework.data.repository.CrudRepository&lt;com.atos.test.account.tables.Day_,java.lang.Long&gt; andorg.springframework.data.repository.Repository&lt;com.atos.test.account.tables.Day_,java.lang.Long&gt; are incompatible; both define count(), but with unrelated return types
  
      Error:(9, 10) java: count() in com.atos.test.account.repository.DayRepository clashes with count() in org.springframework.data.repository.Repository return type long is not compatible with java.lang.Long
  </code></pre>
  
  <p>I've looked into the <code>CrudRepository</code> class but the methods <code>count()</code> is the same than the one I tried. I've also looked into the <code>Repository</code> class because <code>CrudRepository</code> extends it but there is no method count.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>So I think I've resolved the problem :
  Instead of extending my interface to <code>CrudRepository</code>I extended it to <code>Repository</code>. The thing is that I don't know if I can use the same methods ther is in CrudRepository, can I ?</p>