简体   繁体   中英

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM