title: How Do I Write A "Count By" Method Name Query In Spring Data
body: <p>So I know that I can write an interface like the one below and Spring Data will automatically generate the necessary database access stuff for me.  Now what I'd like to do is add a new method name that will count the number of entities that match a set of criteria. </p>
  
  <pre><code>public interface EventRegistrationRepository extends JpaRepository&lt;EventRegistration, String&gt;
  {    
      List&lt;EventRegistration&gt; findByUser_EmailAddress(String email);
  
      int countByEvent_Code(String eventCode);
  }
  </code></pre>
  
  <p>As of now the countBy method causes this error:</p>
  
  <pre><code>Caused by: org.springframework.data.mapping.PropertyReferenceException: No property count found for type com.brazencareerist.brazenconnect.model.relational.EventRegistration
  </code></pre>
  
  <p>What's the proper syntax for what I'm trying to do here?</p>