title: How to order restaurants by votes for a certain date
body: <p>I have restaurants with votes of users. Votes have the field date. I want to get restarants with votes for the certain date ordered by the count of votes. The query is:</p>
  
  <pre><code>SELECT DISTINCT r FROM Restaurant r " +
          "JOIN FETCH r.votes v " +
          "WHERE v.date=?1 " +
          "ORDER BY r.votes.size DESC
  </code></pre>
  
  <p>But it orders restaurants by the votes for all days: </p>
  
  <pre><code>order by
  (select
      count(votes2_.RESTAURANT_ID) 
  from
      votes votes2_ 
  where
      restaurant0_.id=votes2_.RESTAURANT_ID) DESC
  </code></pre>