Imagine a scenario where I am querying the orders table for a list of users and trying to find their orders. I am trying to get a map, with a keyset of user ids, and a list of order objects. return type is similar to this - Map<Integer, List>
JdbiHelper.jdbi(readOnly).withHandle(
handle -> handle.createQuery(query)
.bindList("user_id", userIds).?
The query itself is like :-
SELECT * FROM orders WHERE user_id in (<userIds>)
How do I get a map, with key as user ids and list of order objects as values?
I was trying something along these lines
JdbiHelper.jdbi(readOnly).withHandle(
handle -> handle.createQuery(query)
.bindList("user_id", userIds)
.map((rs, ctx) -> Pair.of(rs.getInt("user_id"), rs))
.collect(toMap(Pair::getLeft, Pair::getRight))
but, it didn't work.