'How to add all result from a Jooq query to a Map
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
Solution 1:[1]
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);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | George Cosmin |
