Hello,
Thanks for the great product!

I am trying to do "upsert" (insert on duplicate key update) while still 
returning ID for the row.

This is my table:

create table test_on_duplicate_key_update (
  id bigint not null primary key auto_increment,

  a varchar(255) not null,
  unique(a),

  b varchar(255)
);

This is how I perform regular insert (Kotlin):

val p = jooq.newRecord(Tables.TEST_ON_DUPLICATE_KEY_UPDATE)
p.a = "a0"
p.b = "b0"
p.store()
// p.id is available here


Now for "upsert", what I do is:

val p = TestOnDuplicateKeyUpdateRow()
p.a = "a1"
p.b = "b1"
jooq
 .insertInto(Tables.TEST_ON_DUPLICATE_KEY_UPDATE)
 .set(p)
 .onDuplicateKeyUpdate()
 .set(p)
 .execute()
// p.id is null :-(


What is the idiomatic way to do this? 


I am using:

- Jooq 3.10.6

- MySQL


Thanks!

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to