domaframework / doma

DAO oriented database mapping framework for Java
https://doma.readthedocs.io/
Apache License 2.0
438 stars 69 forks source link

Add the openStream method to the Criteria API to return a Stream #1111

Closed nakamura-to closed 3 months ago

nakamura-to commented 3 months ago

By using the openStream method, you can process the data associated with the ResultSet one record at a time, reducing memory consumption. Make sure to always close the opened Stream.

Employee_ e = new Employee_();

try (Stream<Employee> stream = nativeSql.from(e).openStream()) {
    stream.forEach(employee -> {
    // do something
    });
}