Getting Started jOOQ

Maven Central JavaDoc

Setting up the environment

Add the Dependency to your build.

for Maven:

Java 8, 9, 10 , 11 no module-info


Java 6, 7


Java 9, 10 , 11 with module-info


From 7.0.0 you will need explicitly include the jOOQ dependency in your pom.

Before :

If you are using jOOQ commercial edition you will need to exclude the dependency as it’s currently scope compiled - will be corrected in next release.


There are 2 mapping strategies available in jOOQ.

because fetchInto has to go through the Record creation, its use will mainly be when your query does not map to a generated object - i.e. a subset of fields or joins -.

SFM as a RecordMapperProvider

Sfm can be plugged into the fetchInto mapping.

All you need to do is


when instantiating your DSL. You will then be able to use fetchInto with a cost very close to fetching the record - see the performance section - and the flexibility that SFM offers.

map subset of select fields


#SFM as a RecordUnmapperProvider

From 8.2.0 we now have a RecordUnmapper available from the JooqMapperFactory.



In 8.2.0 we also introduced the SelectQueryMapper that can deals with join with minimum of effort. It will uses the jOOQ model to determined which field is a key, and also activate the speculative object mapping removing the need for aliasing. The following will now just work out of the box:

SelectQueryMapper<Author> authorMapper = SelectQueryMapperFactory.newInstance().newMapper(Author.class);

List<Author> authors = authorMapper.asList(DSL.using(connection)
                BOOK.ID, BOOK.TITLE)

no need for key definitions or aliasing anymore.

SFM on the ResultSet

Because the RecordMapperProvider works on the record that we don’t need we are not as performant as working directly with the ResultSet. Fortunately, jOOQ allows you to fetch the ResultSet directly avoiding the cost of the transition from ResultSet to Record.

JdbcMapper mapper = JdbcMapperFactory.newInstance().newMapper(MyObject.class);

ResultQuery<MyRecord> query =;
try (ResultSet rs = query.fetchResultSet()) {;

That will allow you to get the query generation power of jOOQ and the close to pure Jdbc performance of SimpleFlatMapper.


The join aggregation is only available when using SFM on the result set as the RecordMapper interface expect one object per row.