jOOQ 3.14 will support UpdatableRecord.merge() for this purpose: 
https://github.com/jOOQ/jOOQ/issues/2961

On Tuesday, October 25, 2016 at 11:25:19 PM UTC+2, Lukas Eder wrote:
>
> Hi Denis,
>
> UpdatableRecord currently doesn't have an "UPSERT" feature (or INSERT ON 
> DUPLICATE KEY UPDATE, etc.) This is a pending feature request:
> https://github.com/jOOQ/jOOQ/issues/2961
>
> I guess we've postponed it long enough now, it shouldn't be too hard to 
> implement...
> In the meantime, you can pass your record to an actual INSERT ON DUPLICATE 
> KEY UPDATE statement:
>
> ctx.insertInto(MYTABLE)
>    .set(rec)
>    .onDuplicateKeyUpdate()
>    .set(rec) // Maybe manually reset the PK columns again, here...
>    .execute();
>
>
> Hope this helps,
> Lukas
>
> 2016-10-22 16:05 GMT+02:00 Denis Miorandi <denis.miora...@gmail.com>:
>
>> I'm trying to use UpdatableRecord store() method, but it's not clear to 
>> me the right way.
>> In my scenario I would like 
>>
>>    - create a record in memory, so 
>>    - store record wheter exists or not so )
>>
>> rec=ctx.newRecord(MYTABLE)
>> rec.setField1(1)
>> rec.setField2(1)
>> ....
>> rec.store()
>>
>> Issue is store() try to always insert it (wheter exists or not on db) 
>> cause not loaded from db with rec.refresh(),
>> so that I've tried to do same thing using a refresh on rec (after set 
>> keys before set other values) but refresh()
>> fail is record doesn't exists. So:
>>
>>
>>    - refresh() works only on existings records
>>    - store() works only if a record is loaded from refresh() otherwise 
>>    always insert
>>
>> Am I right? Am I missunderstanding something?
>> How can I store a new record wheter exists or not on db?
>>
>> Tks
>> Denis
>>
>>
>> -- 
>> 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.
>>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/50f00d2f-1f29-4905-8a36-aa3e10ebe60a%40googlegroups.com.

Reply via email to