Skip to main content

Result Sets

Result set parsers handle the full lifecycle of reading from a ResultSet. They build on top of row parsers to provide convenient ways to consume query results.

ResultSetParser

A ResultSetParser<T> reads a complete ResultSet and produces a value of type T. You typically create one from a RowParser:

// Parse a single optional result
ResultSetParser<Optional<Person>> singleParser = personParser.singleOpt();

// Parse all results as a list
ResultSetParser<List<Person>> listParser = personParser.list();

// Execute with automatic resource management
Optional<Person> person = singleParser.parse(resultSet);

Available Parsers

From any RowParser<T> you can create:

MethodReturnsDescription
.list()List<T>All rows as a list
.singleOpt()Optional<T> / T? / Option[T]Zero or one row (throws if more than one)
.single()TExactly one row (throws otherwise)