title: Rollup with GroupBy using QueryDSL and PostgreSQL database
body: <p>I am using QueryDSL to form queries in Java8. Database is PostgreSQL.</p>
  
  <p>For one of the features I need to use the ROLLUP functionality with GroupBy in PostgreSQL but I am unable to do the same using QueryDSL methods. I am also very new to QueryDSL.</p>
  
  <p>Presently, this is how my query builder code looks like. </p>
  
  <pre class="lang-java prettyprint-override"><code>JPAQuery query = repository.getQueryDSL().createQuery(QEntity.entity).where(finalPredicate)
                  .groupBy(groupByFields.toArray(new Expression[0]))
                  .orderBy(orderSpecifierArray)
                  .limit(pageSize);
  </code></pre>
  
  <p>// to fetch the results</p>
  
  <pre class="lang-java prettyprint-override"><code>query.select(alarmProjectionFactory).fetch()
  </code></pre>
  
  <p>I want to include ROLLUP with the above .groupBy method.</p>
  
  <p>In the final query I want something like this:</p>
  
  <pre class="lang-sql prettyprint-override"><code>GROUP BY Rollup(field1, field2)
  </code></pre>
  
  <p>instead of:</p>
  
  <pre class="lang-sql prettyprint-override"><code>GROUP BY field1, field2.
  </code></pre>
  
  <p>Please suggest if its possible to do in code using QueryDSL and the changes required.</p>