title: Count(*) (asterisk) on Querydsl / MySQL?
body: <p>The original functional MySQL query that lists all and only the providers that have all the listed tags:</p>
  
  <pre><code>SELECT * FROM provider
    INNER JOIN provider_tag
    ON provider_tag.provider_id = provider.id AND provider_tag.tag_id in (1, 2)
    GROUP BY (provider.id)
    HAVING COUNT(*) = 2
  </code></pre>
  
  <p>Translating to MySQLQuery in Querydsl is straightforward...</p>
  
  <pre><code>MySQLQuery query = new MySQLQuery(conn, dialect);
  
  List&lt;Integer&gt; tagIds = ...;
  
  query.from(provider)
      .innerJoin(provider_tag)
      .on(providerTag.providerId.eq(provider.id), providerTag.tagId.in(tagIds))
      .groupBy(provider.id)
      .having(???);
  </code></pre>
  
  <p>... except for the condition in <code>having</code>.</p>
  
  <p>How do I add <code>COUNT(*)</code> to the query?</p>
  
  <p><strong>EDIT after Timo's 1st correction proposal</strong>:</p>
  
  <p>So, the query looks like this:</p>
  
  <pre><code>SearchResults&lt;Tuple&gt; result = query.from(provider)
      .innerJoin(providerTag)
      .on(providerTag.providerId.eq(provider.id), providerTag.tagId.in(tagIds))
      .groupBy(provider.id)
      .having(Wildcard.count.eq((long) tagIds.size()))
      .listResults(
          provider.id,
          provider.name);
  </code></pre>
  
  <p>However, this causes an SQLException <code>Illegal operation on empty result set</code>, if the result set is empty.</p>
  
  <p>My other queries that return an empty result set do not cause exceptions, so I guess I should not need to catch the exception, but there is a problem that should be fixed?</p>
  
  <p>The generated MySQL works perfectly (returns 0 rows), so the problem is not there.</p>
  
  <p><strong>EDIT 2</strong>:</p>
  
  <p>The problem was in <code>groupBy()</code>. This seems to work, if one applies the correction shown in the <a href="https://github.com/querydsl/querydsl/issues/1055" rel="nofollow">issue</a>.</p>