如何将 Jooq 查询的所有结果添加到地图
How to add all result from a Jooq query to a Map
我想像这样添加来自 jooq 查询 (MySQL) 的所有结果:
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));
变成像Map> mapList这样的地图;
如何修改查询以便可以将数据保存在该地图中?
谢谢
已解决
这是针对我的问题的正确查询:)
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);
我想像这样添加来自 jooq 查询 (MySQL) 的所有结果:
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));
变成像Map
如何修改查询以便可以将数据保存在该地图中?
谢谢
已解决
这是针对我的问题的正确查询:)
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);