NoSuchMethod in JOOQ 3.14 InsertQuery with Postgresql

Tags: , , ,

I’m trying to use Jooq’s InsertQuery to insert a record into PostgresQL database, but I’m running into following error:

java.lang.NoSuchMethodError: 'org.jooq.UniqueKey org.jooq.impl.Internal.createUniqueKey(org.jooq.Table, org.jooq.Name, org.jooq.TableField[], boolean)'
at fi.eriran.generated.jooq.Keys.<clinit>( ~[classes/:na]
at fi.eriran.generated.jooq.tables.User.getPrimaryKey( ~[classes/:na]
at org.jooq.impl.UpdatableRecordImpl.getPrimaryKey( ~[jooq-3.13.4.jar:na]
at org.jooq.impl.AbstractRecord.set( ~[jooq-3.13.4.jar:na]
at org.jooq.impl.AbstractRecord.set( ~[jooq-3.13.4.jar:na]
at fi.eriran.generated.jooq.tables.records.UserRecord.setUsername( ~[classes/:na]
at fi.eriran.criminalapi.main.dao.user.query.UserQuery.createInsertRecord( ~[classes/:na]
at fi.eriran.criminalapi.main.dao.user.query.UserQuery.insert( ~[classes/:na]

The query class I’m using looks like this:

public class UserQuery {

private DslContext ctx;

public InsertQuery<UserRecord> insert(NewUser newUser) {
    InsertQuery<UserRecord> insertQuery = ctx.insertQuery(USER);
    return insertQuery;

private UserRecord createInsertRecord(NewUser newUser) {
    UserRecord userRecord = new UserRecord();
    return userRecord;

The user database table looks like this. It has a unique key on the username column and a primary key on the id column.

CREATE TABLE criminal."user" (
id serial NOT NULL,
username varchar(500) NOT NULL,
"password" varchar(500) NOT NULL,
created_at timestamptz(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT user_un UNIQUE (username)
CREATE INDEX user_username_idx ON criminal."user" (username);

If I do this using ctx.insertInto… it works fine. I initially used Jooq 3.14.0 but upgrading to the latest 3.14.4 did not help here. Something must be wrong with the generated Keys class since everything works until Keys class is initialized. Is something wrong with either the Postgresql table structure or could something have gone wrong with the code generation?

Full repo here:


You’re saying you’re using jOOQ 3.14, yet on your stack trace, there is a reference to version 3.13.4:

at org.jooq.impl.UpdatableRecordImpl.getPrimaryKey( ~[jooq-3.13.4.jar:na]

You probably have set up your classpath incorrectly. Both the jOOQ version to generate code, and the jOOQ version to run your code must be the same.

Source: stackoverflow