package net.apnic.example.jdbcstream;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jdbc.datasource.embedded.ConnectionProperties;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseConfigurer;

import javax.sql.DataSource;

@SpringBootApplication
public class JdbcStreamApplication implements EmbeddedDatabaseConfigurer{

    public static void main(String[] args) {
        SpringApplication.run(JdbcStreamApplication.class, args);
    }

    @Override
    public void configureConnectionProperties(ConnectionProperties connectionProperties, String s) {

    }

    @Override
    public void shutdown(DataSource dataSource, String s) {

    }
}

@@ -144,32 +144,135 @@
 ootApplication;%0A
+import org.springframework.context.annotation.Bean;%0Aimport org.springframework.jdbc.core.JdbcTemplate;%0A
 import org.sprin
@@ -413,36 +413,405 @@
 er;%0A
-%0Aimport javax.sql.DataSource
+import org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet;%0Aimport org.springframework.jdbc.support.rowset.SqlRowSet;%0A%0Aimport javax.sql.DataSource;%0Aimport java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0Aimport java.util.Spliterator;%0Aimport java.util.Spliterators;%0Aimport java.util.function.Function;%0Aimport java.util.stream.Stream;%0Aimport java.util.stream.StreamSupport
 ;%0A%0A@
@@ -904,16 +904,17 @@
 nfigurer
+ 
 %7B%0A%0A    p
@@ -1018,32 +1018,1880 @@
 , args);%0A    %7D%0A%0A
+    public interface QueryStream %7B%0A        public %3CT%3E T streamQuery(String sql, Function%3CStream%3CSqlRowSet%3E, ? extends T%3E streamer, Object... args);%0A    %7D%0A%0A    private enum IsParallel %7B%0A        SEQUENTIAL(false),%0A        PARALLEL(true);%0A%0A        private final boolean flag;%0A%0A        IsParallel(boolean flag) %7B%0A            this.flag = flag;%0A        %7D%0A%0A        boolean getFlag() %7B return flag; %7D%0A    %7D%0A%0A    /**%0A     * The gist code at%0A     *   https://gist.github.com/codebje/58d1b12e7a2d0ed31b3a#file-jdbcstreams-java%0A     *%0A     * @param jdbcTemplate the JdbcTemplate to use%0A     * @return a QueryStream instance%0A     */%0A    @Bean%0A    public QueryStream streamer(JdbcTemplate jdbcTemplate) %7B%0A        return new QueryStream() %7B%0A            @Override%0A            public %3CT%3E T streamQuery(String sql, Function%3CStream%3CSqlRowSet%3E, ? extends T%3E streamer, Object... args) %7B%0A                return jdbcTemplate.query(sql, resultSet -%3E %7B%0A                    final SqlRowSet rowSet = new ResultSetWrappingSqlRowSet(resultSet);%0A%0A                    Spliterator%3CSqlRowSet%3E spliterator = Spliterators.spliteratorUnknownSize(new Iterator%3CSqlRowSet%3E() %7B%0A                        @Override%0A                        public boolean hasNext() %7B%0A                            return !rowSet.isLast();%0A                        %7D%0A%0A                        @Override%0A                        public SqlRowSet next() %7B%0A                            if (!rowSet.next()) %7B%0A                                throw new NoSuchElementException();%0A                            %7D%0A                            return rowSet;%0A                        %7D%0A                    %7D, Spliterator.IMMUTABLE);%0A                    return streamer.apply(StreamSupport.stream(spliterator,%0A                            IsParallel.SEQUENTIAL.getFlag()));%0A                %7D, args);%0A            %7D%0A        %7D;%0A    %7D%0A%0A
     @Override%0A  

Add the gist code (plus IsParallel over-the-top type safety)