title: How to count records of particular id in spring boot and hibernate
body: <p>I am working on a project using Spring boot and hibernate. I want to count records against an id in table. I can count all records of the table but unable to count records against a foreign key.</p>
  
  <p>Here is my controller code</p>
  
  <pre><code>@RequestMapping("/rating/{id}")
  @ResponseBody 
   public long getRatingInfo(@PathVariable("id") long id, HttpServletRequest req, HttpServletResponse res) throws Exception {
  
  long postobj = myDao.count();
  return postobj;
  }
  </code></pre>
  
  <p>Here i am passing an <code>id</code> in url but there is no method of <code>count</code> to pass this id to find records.</p>
  
  <p>And here is my Dao Interface</p>
  
  <pre><code>@Transactional
  public interface MyDaoInterface extends CrudRepository&lt;Rating, Long&gt;{
  }
  </code></pre>