Reputation: 121
I want to add all results from a jooq query (MySQL) like this:
organizationDSLContext.select(
Tables.USER_ORGANIZATION_ROLE.ID_ORGANIZATION,
DSL.jsonArrayAgg(Tables.USER_ORGANIZATION_ROLE.ID_ROLE))
.from(Tables.USER_ORGANIZATION_ROLE)
.where(Tables.USER_ORGANIZATION_ROLE.ID_USER.eq(UserService.DEFAULT_ID_USER))
.groupBy(Tables.USER_ORGANIZATION_ROLE.ID_ORGANIZATION)
.fetchGroups(Tables.USER_ORGANIZATION_ROLE.ID_ORGANIZATION, DSL.jsonArrayAgg(Tables.USER_ORGANIZATION_ROLE.ID_ROLE));
Into a map like Map<Integer, List<'Integer>> mapList;
How can I modify the query so that I can save the data in that map?
Thanks
Upvotes: 3
Views: 180
Reputation: 121
SOLVED
This is the correct query for my problem :)
Map<Integer, List<Integer>> mapList = organizationDSLContext.selectFrom(Tables.USER_ORGANIZATION_ROLE)
.where(Tables.USER_ORGANIZATION_ROLE.ID_USER.eq(UserService.DEFAULT_ID_USER))
.fetchGroups(Tables.USER_ORGANIZATION_ROLE.ID_ORGANIZATION, Tables.USER_ORGANIZATION_ROLE.ID_ROLE);
Upvotes: 3