i'm trying to implement save or update method using jooq and table with unique constraint "phone_number_key"
My code:
var insertStep = dslContext.insertInto(Users.USERS)
.set(Users.USERS.FIRSTNAME, user.getFirstname())
.set(Users.USERS.PHONENUMBER, user.getPhoneNumber())
.onConflict()
.doUpdate()
.set(Users.USERS.FIRSTNAME, user.getFirstname())
.returningResult(Users.USERS.ID);
var record = insertStep.fetchOne();
but i got exception
ERROR: duplicate key value violates unique constraint "phone_number_key" Detail: Key ("phoneNumber")=(+999999999) already exists.
I got same error with ".onDuplicateKeyUpdate()" method
I use postgres db
What am i doing wrong ?