QueryDSL 4, map and count

1,417 views
Skip to first unread message

Guillaume Smet

unread,
Oct 14, 2015, 5:29:21 AM10/14/15
to Querydsl
Hi,

I'm trying to migrate the following code to QueryDSL 4:
JPQLQuery query = new JPAQuery(getEntityManager());
       
        query
.from(qTicket)
           
.where(qTicket.heliosContract.eq(heliosContract))
           
.groupBy(qTicket.state);
       
       
return query.map(qTicket.state, qTicket.count());

Based on the example from the documentation, I tried something like:
JPQLQuery<Void> query = new JPAQuery<>(getEntityManager());
       
        query
.from(qTicket)
           
.where(qTicket.heliosContract.eq(heliosContract));
       
       
return query.transform(GroupBy.groupBy(qTicket.state), GroupBy.as(qTicket.count()));

But GroupBy.as doesn't accept my count() expression.

Any hint would be greatly appreciated.

Thanks!

Ruben Dijkstra

unread,
Oct 14, 2015, 6:10:04 AM10/14/15
to Guillaume Smet via Querydsl

Hi,

 

I think that ‘transform(GroupBy.groupBy(qTicket.state).as(qTicket.count()))’ should work.

 

Is it an issue in the documentation? Could you then open up an issue for that?

 

Br,

 

Ruben

--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

 

Guillaume Smet

unread,
Oct 14, 2015, 8:49:53 AM10/14/15
to Querydsl on behalf of Ruben Dijkstra, Guillaume Smet via Querydsl
Hi Ruben,

On Wed, Oct 14, 2015 at 12:09 PM, Querydsl on behalf of Ruben Dijkstra <quer...@googlegroups.com> wrote:

I think that ‘transform(GroupBy.groupBy(qTicket.state).as(qTicket.count()))’ should work.

Yes, it works. I misread the doc... Sorry for the noise.

Reply all
Reply to author
Forward
0 new messages