Skip to content

Allow streaming of selection results #40

@jenetics

Description

@jenetics

Currently it is only possible to fetch the result of a SQL query eagerly.

final List<Book> books = Query.of("SELECT * FROM book WHERE title ilike :title")
    .on(value("title", "%" + title.toLowerCase() + "%"))
    .as(PARSER.list(), conn);

It should additionally be possible to do the fetch lazily.

final Stream<Book> books = Query.of("SELECT * FROM book WHERE title ilike :title")
    .on(value("title", "%" + title.toLowerCase() + "%"))
    .as(PARSER.stream(), conn);

// The stream must be closed explicitly to close and release the underlying
// `ResultSet` object.
try (stream) {
    stream.forEach(System.out::println);
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions