java - JOOQ Retrieving a Map from selectCount -
i trying map map , has booktype , count information jooq. have tried following , different combinations keep getting errors. appreciated:
map<string, result<record1<integer>>> countmap = ctx.selectcount().from(booktable) .groupby(booktable.type) .fetchmap(booktable.type);
you cannot use selectcount()
in case, because produce select count(*)
query, when want select type, count(*)
query.
here several ways how that, depending on type you're trying out of query:
// assuming static import: import static org.jooq.impl.dsl.*; map<string, integer> map1 = ctx.select(booktable.type, count()) .from(booktable) .groupby(booktable.type) .fetchmap(booktable.type, count());
or:
map<string, record2<string, integer>> map2 = ctx.select(booktable.type, count()) .from(booktable) .groupby(booktable.type) .fetchmap(booktable.type);
or:
map<string, list<integer>> map3 = ctx.select(booktable.type, count()) .from(booktable) .groupby(booktable.type) .fetchgroups(booktable.type, count());
or:
map<string, result<record2<string, integer>>> map4 = ctx.select(booktable.type, count()) .from(booktable) .groupby(booktable.type) .fetchgroups(booktable.type);
Comments
Post a Comment