bootiful-sqltemplate-core/src/main/java/ninja/cero/sqltemplate/core/SqlTemplate.java
public <T, U> U forStream(
            String fileName,
            Class<T> clazz,
            Object entity,
            Function<? super Stream<T>, U> handleStream) {
        String sql = getTemplate(fileName, entity);
        RowMapper<T> mapper = mapperBuilder.mapper(clazz);
        SQLExceptionTranslator excTranslator = jdbcTemplate.getExceptionTranslator();
        if (TypeUtils.isSimpleValueType(entity.getClass())) {
            PreparedStatementSetter pss = paramBuilder.byArgs(entity);
            return queryStreamWithOrdinalParams(sql, pss, mapper, handleStream);
        } else {
            SqlParameterSource sps = paramBuilder.byBean(entity);
            return queryStreamWithNamedParams(sql, sps, mapper, handleStream);
        }
    }
public <T, U> U forStream(
            String fileName,
            Class<T> clazz,
            Object entity,
            Function<? super Stream<T>, U> handleStream) {
        String sql = getTemplate(fileName, entity);
        RowMapper<T> mapper = mapperBuilder.mapper(clazz);
        SQLExceptionTranslator excTranslator = jdbcTemplate.getExceptionTranslator();
        if (TypeUtils.isSimpleValueType(entity.getClass())) {
            PreparedStatementSetter pss = paramBuilder.byArgs(entity);
            return queryStreamWithOrdinalParams(sql, pss, mapper, handleStream);
        } else {
            SqlParameterSource sps = paramBuilder.byBean(entity);
            return queryStreamWithNamedParams(sql, sps, mapper, handleStream);
        }
    }
Executes a query, passing the row objects to {@code handleStream} as a stream.

<p>{@code entity} is used as the single parameter if it is a simple value,
or as the container of the named parameters if it is a bean.</p>

<p>Example usage with a simple value parameter:</p>

<pre>
int totalSalary = sqlTemplate.forStream("/path/to/query.sql", Emp.class, "SALESMAN",
empStream -&gt; empStream.mapToInt(Emp::getSalary).sum());
</pre>

<p>Example usage with a bean parameter:</p>

<pre>
emp.setDeptno(30);
emp.setJob("SALESMAN");
int totalSalary = sqlTemplate.forStream("/path/to/query.sql", Emp.class, emp,
empStream -&gt; empStream.mapToInt(Emp::getSalary).sum());
</pre>

@param fileName parameterized SQL specifier
@param clazz the result object class
@param entity the single parameter, or the container of the named parameters
@param handleStream  the function which is applied to the stream
@param <T> the row object type
@param <U> the result type
@return the result of {@code handleStream}
@throws org.springframework.dao.DataAccessException if there is any problem