application/src/main/java/demo/dom/tables/pojos/Author.java
@Generated(
	value = {
		"http://www.jooq.org",
		"jOOQ version:3.7.0"
	},
	comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Author implements Serializable {

	private static final long serialVersionUID = -2018295126;

	private Long   id;
	private String name;

	public Author() {}

	public Author(Author value) {
		this.id = value.id;
		this.name = value.name;
	}

	public Author(
		Long   id,
		String name
	) {
		this.id = id;
		this.name = name;
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Author other = (Author) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		}
		else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		}
		else if (!name.equals(other.name))
			return false;
		return true;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder("Author (");

		sb.append(id);
		sb.append(", ").append(name);

		sb.append(")");
		return sb.toString();
	}
}
application/src/main/java/demo/repository/AuthorRepository.java
public class AuthorRepository extends AuthorDao {

	public AuthorRepository(Configuration configuration) {
		super(configuration);
	}

}
application/src/main/java/demo/dom/tables/records/RAuthorRecord.java
@Generated(
	value = {
		"http://www.jooq.org",
		"jOOQ version:3.7.0"
	},
	comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class RAuthorRecord extends UpdatableRecordImpl<RAuthorRecord> implements Record2<Long, String> {

	private static final long serialVersionUID = 1732267430;

	/**
	 * Setter for <code>PUBLIC.AUTHOR.ID</code>.
	 */
	public void setId(Long value) {
		setValue(0, value);
	}

	/**
	 * Getter for <code>PUBLIC.AUTHOR.ID</code>.
	 */
	public Long getId() {
		return (Long) getValue(0);
	}

	/**
	 * Setter for <code>PUBLIC.AUTHOR.NAME</code>.
	 */
	public void setName(String value) {
		setValue(1, value);
	}

	/**
	 * Getter for <code>PUBLIC.AUTHOR.NAME</code>.
	 */
	public String getName() {
		return (String) getValue(1);
	}

	// -------------------------------------------------------------------------
	// Primary key information
	// -------------------------------------------------------------------------

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Record1<Long> key() {
		return (Record1) super.key();
	}

	// -------------------------------------------------------------------------
	// Record2 type implementation
	// -------------------------------------------------------------------------

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Row2<Long, String> fieldsRow() {
		return (Row2) super.fieldsRow();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Row2<Long, String> valuesRow() {
		return (Row2) super.valuesRow();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Field<Long> field1() {
		return TAuthor.AUTHOR.ID;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Field<String> field2() {
		return TAuthor.AUTHOR.NAME;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Long value1() {
		return getId();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String value2() {
		return getName();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public RAuthorRecord value1(Long value) {
		setId(value);
		return this;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public RAuthorRecord value2(String value) {
		setName(value);
		return this;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public RAuthorRecord values(Long value1, String value2) {
		value1(value1);
		value2(value2);
		return this;
	}

	// -------------------------------------------------------------------------
	// Constructors
	// -------------------------------------------------------------------------

	/**
	 * Create a detached RAuthorRecord
	 */
	public RAuthorRecord() {
		super(TAuthor.AUTHOR);
	}

	/**
	 * Create a detached, initialised RAuthorRecord
	 */
	public RAuthorRecord(Long id, String name) {
		super(TAuthor.AUTHOR);

		setValue(0, id);
		setValue(1, name);
	}
}
hibernate/src/main/java/demo/repository/BookRepository.java
public interface BookRepository extends JpaRepository<Book, Long> {
}
hibernate/src/main/java/demo/domain/AuthorWithBooks.java
public class AuthorWithBooks {

	private Author author;
	private List<Book> books = Collections.emptyList();

	public AuthorWithBooks() {
	}

	public AuthorWithBooks(Author author, List<Book> books) {
		this.author = author;
		this.books = books;
	}

	private AuthorWithBooks(Builder builder) {
		setAuthor(builder.author);
		setBooks(builder.books);
	}

	public static Builder newBuilder() {
		return new Builder();
	}

	public static Builder newBuilder(AuthorWithBooks copy) {
		Builder builder = new Builder();
		builder.author = copy.author;
		builder.books = copy.books;
		return builder;
	}

	public Author getAuthor() {
		return author;
	}

	public void setAuthor(Author author) {
		this.author = author;
	}

	public List<Book> getBooks() {
		return books;
	}

	public void setBooks(List<Book> books) {
		this.books = books;
	}


	public static final class Builder {
		private Author author;
		private List<Book> books;

		private Builder() {
		}

		public Builder author(Author val) {
			author = val;
			return this;
		}

		public Builder books(List<Book> val) {
			books = val;
			return this;
		}

		public AuthorWithBooks build() {
			return new AuthorWithBooks(this);
		}
	}


	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		AuthorWithBooks that = (AuthorWithBooks) o;

		if (!getAuthor().equals(that.getAuthor())) return false;
		return getBooks().equals(that.getBooks());

	}

	@Override
	public int hashCode() {
		int result = getAuthor().hashCode();
		result = 31 * result + getBooks().hashCode();
		return result;
	}
}
application/src/main/java/demo/dom/tables/pojos/Book.java
@Generated(
	value = {
		"http://www.jooq.org",
		"jOOQ version:3.7.0"
	},
	comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Book implements Serializable {

	private static final long serialVersionUID = 211230648;

	private Long   id;
	private String title;

	@JsonIgnore
	private Long   authorId;

	public Book() {}

	public Book(Book value) {
		this.id = value.id;
		this.title = value.title;
		this.authorId = value.authorId;
	}

	public Book(
		Long   id,
		String title,
		Long   authorId
	) {
		this.id = id;
		this.title = title;
		this.authorId = authorId;
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Long getAuthorId() {
		return this.authorId;
	}

	public void setAuthorId(Long authorId) {
		this.authorId = authorId;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Book other = (Book) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		}
		else if (!id.equals(other.id))
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		}
		else if (!title.equals(other.title))
			return false;
		if (authorId == null) {
			if (other.authorId != null)
				return false;
		}
		else if (!authorId.equals(other.authorId))
			return false;
		return true;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		result = prime * result + ((authorId == null) ? 0 : authorId.hashCode());
		return result;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder("Book (");

		sb.append(id);
		sb.append(", ").append(title);
		sb.append(", ").append(authorId);

		sb.append(")");
		return sb.toString();
	}
}
application/src/main/java/demo/dom/tables/TBook.java
public static final TBook BOOK = new TBook();
application/src/main/java/demo/dom/tables/TAuthor.java
@Generated(
	value = {
		"http://www.jooq.org",
		"jOOQ version:3.7.0"
	},
	comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TAuthor extends TableImpl<RAuthorRecord> {

	private static final long serialVersionUID = 996098554;

	/**
	 * The reference instance of <code>PUBLIC.AUTHOR</code>
	 */
	public static final TAuthor AUTHOR = new TAuthor();

	/**
	 * The class holding records for this type
	 */
	@Override
	public Class<RAuthorRecord> getRecordType() {
		return RAuthorRecord.class;
	}

	/**
	 * The column <code>PUBLIC.AUTHOR.ID</code>.
	 */
	public final TableField<RAuthorRecord, Long> ID = createField("ID", org.jooq.impl.SQLDataType.BIGINT.nullable(false).defaulted(true), this, "");

	/**
	 * The column <code>PUBLIC.AUTHOR.NAME</code>.
	 */
	public final TableField<RAuthorRecord, String> NAME = createField("NAME", org.jooq.impl.SQLDataType.VARCHAR.length(50).nullable(false), this, "");

	/**
	 * Create a <code>PUBLIC.AUTHOR</code> table reference
	 */
	public TAuthor() {
		this("AUTHOR", null);
	}

	/**
	 * Create an aliased <code>PUBLIC.AUTHOR</code> table reference
	 */
	public TAuthor(String alias) {
		this(alias, AUTHOR);
	}

	private TAuthor(String alias, Table<RAuthorRecord> aliased) {
		this(alias, aliased, null);
	}

	private TAuthor(String alias, Table<RAuthorRecord> aliased, Field<?>[] parameters) {
		super(alias, TPublic.PUBLIC, aliased, parameters, "");
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Identity<RAuthorRecord, Long> getIdentity() {
		return Keys.IDENTITY_AUTHOR;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public UniqueKey<RAuthorRecord> getPrimaryKey() {
		return Keys.PK_AUTHOR;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<UniqueKey<RAuthorRecord>> getKeys() {
		return Arrays.<UniqueKey<RAuthorRecord>>asList(Keys.PK_AUTHOR);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public TAuthor as(String alias) {
		return new TAuthor(alias, this);
	}

	/**
	 * Rename this table
	 */
	public TAuthor rename(String name) {
		return new TAuthor(name, null);
	}
}
application/src/main/java/demo/dom/tables/TAuthor.java
public static final TAuthor AUTHOR = new TAuthor();
application/src/main/java/demo/dom/tables/TBook.java
@Generated(
	value = {
		"http://www.jooq.org",
		"jOOQ version:3.7.0"
	},
	comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class TBook extends TableImpl<RBookRecord> {

	private static final long serialVersionUID = -146557646;

	/**
	 * The reference instance of <code>PUBLIC.BOOK</code>
	 */
	public static final TBook BOOK = new TBook();

	/**
	 * The class holding records for this type
	 */
	@Override
	public Class<RBookRecord> getRecordType() {
		return RBookRecord.class;
	}

	/**
	 * The column <code>PUBLIC.BOOK.ID</code>.
	 */
	public final TableField<RBookRecord, Long> ID = createField("ID", org.jooq.impl.SQLDataType.BIGINT.nullable(false).defaulted(true), this, "");

	/**
	 * The column <code>PUBLIC.BOOK.TITLE</code>.
	 */
	public final TableField<RBookRecord, String> TITLE = createField("TITLE", org.jooq.impl.SQLDataType.VARCHAR.length(50).nullable(false), this, "");

	/**
	 * The column <code>PUBLIC.BOOK.AUTHOR_ID</code>.
	 */
	public final TableField<RBookRecord, Long> AUTHOR_ID = createField("AUTHOR_ID", org.jooq.impl.SQLDataType.BIGINT, this, "");

	/**
	 * Create a <code>PUBLIC.BOOK</code> table reference
	 */
	public TBook() {
		this("BOOK", null);
	}

	/**
	 * Create an aliased <code>PUBLIC.BOOK</code> table reference
	 */
	public TBook(String alias) {
		this(alias, BOOK);
	}

	private TBook(String alias, Table<RBookRecord> aliased) {
		this(alias, aliased, null);
	}

	private TBook(String alias, Table<RBookRecord> aliased, Field<?>[] parameters) {
		super(alias, TPublic.PUBLIC, aliased, parameters, "");
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Identity<RBookRecord, Long> getIdentity() {
		return Keys.IDENTITY_BOOK;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public UniqueKey<RBookRecord> getPrimaryKey() {
		return Keys.PK_BOOK;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<UniqueKey<RBookRecord>> getKeys() {
		return Arrays.<UniqueKey<RBookRecord>>asList(Keys.PK_BOOK);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public TBook as(String alias) {
		return new TBook(alias, this);
	}

	/**
	 * Rename this table
	 */
	public TBook rename(String name) {
		return new TBook(name, null);
	}
}


Question: package demo.service;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import org.jooq.Cursor;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.RecordMapper;
import org.jooq.Result;
import org.jooq.TableField;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import demo.dom.tables.TAuthor;
import demo.dom.tables.TBook;
import demo.dom.tables.pojos.Author;
import demo.dom.tables.pojos.Book;
import demo.dom.tables.records.RAuthorRecord;
import demo.domain.AuthorWithBooks;
import demo.repository.AuthorRepository;
import demo.repository.BookRepository;
import static demo.dom.tables.TAuthor.AUTHOR;
import static demo.dom.tables.TBook.BOOK;





/**
 * Created by nlabrot on 30/09/15.
 */
@Service
public class AuthorQueries {

	@Autowired
	private AuthorRepository authorRepository;

	@Autowired
	private BookRepository bookRepository;

	@Autowired
	private DSLContext dslContext;

	@Autowired
	private JdbcTemplate jdbcTemplate;


	@Transactional(readOnly = true)
	public Long reference() {
		Set<Long> set = new HashSet<>();
		AtomicLong aLong = new AtomicLong();
		jdbcTemplate.query("SELECT AUTHOR.*, BOOK.* FROM AUTHOR LEFT OUTER JOIN BOOK ON AUTHOR.ID = BOOK.AUTHOR_ID", r -> {
			Long authorId = r.getLong("AUTHOR.ID");
			if (!set.contains(authorId)) {
				set.add(authorId);
				aLong.addAndGet(r.getString("AUTHOR.NAME").length());
			}
			aLong.addAndGet(r.getLong("BOOK.ID"));
			aLong.addAndGet(r.getString("BOOK.TITLE").length());
		});
		return aLong.get();

	}

	@Transactional(readOnly = true)
Answer: 	public Collection<AuthorWithBooks> findAuthorsWithBooksJdbc() {