Hibernate Criteria - Excluding group by clause in the select statement
<p>I've written this in sql server: </p>

<pre><code>select max(processed_trans_id) from EQUITY_TRANSACTION where transaction_date &lt;= '2016-06-22' and company_id=75 group by comp_acct_id
</code></pre>

<p>But when I try to write the same in Hibernate Criteria, like this: </p>

<pre><code>DetachedCriteria dCriteria = DetachedCriteria.forClass(EquityTransaction.class)
            .add(Restrictions.eq("clientCompany.id", sb.getClientCompany().getId()))
            .add(Restrictions.le("transactionDate", sb.getQualifyDate()))
            .setProjection(Projections.projectionList()
                    .add(Projections.max("processedTransaction.id"), "processedTransaction.id")
                    .add(Projections.groupProperty("holderCompanyAccount.id")));
</code></pre>

<p>I get this as the sql query from hibernate:</p>

<pre><code>select max(processed_trans_id), comp_acct_id from EQUITY_TRANSACTION where transaction_date &lt;= '2016-06-22' and company_id=75 group by comp_acct_id
</code></pre>

<p>How do I replicate the original SQL query in Hibernate criteria?</p>