Cemre Mengü
Cemre Mengü

Reputation: 18774

JDBI: How to map query as list of objects

I am using JDBI to iterate through a resultset via streams. Currently mapToMap is causing problems when there is a column with the same name in the result. What I need is just the values without the column names.

Is there a way to map the results to an Object list/array? The docs does not have an example for this. I would like to have something like

query.mapTo(List<Object>.class).useStream(s -> { . . .})

Upvotes: 0

Views: 1343

Answers (1)

winson
winson

Reputation: 428

First of all - what kind of use case would allow you not care at all about the column name but only the values? I am genuinely curious

If it does make sense, it is trivial to implement a RowMapper<List<Object>> in your case, which runs through all the columns by index and puts the results of rs.getObject(i) into a list.

Upvotes: 2

Related Questions