Make getTotalRecords compatible with groupBy in the DQL