Hmm, this makes me wonder if we should add another flag that helps turning
off optimistic locking in the absence of a version / timestamp column...
You shouldn't have to remember this - neither for batching, nor for general
record insertion.

I have created a feature request for this:
https://github.com/jOOQ/jOOQ/issues/5384

This is certainly easier to implement than the bugfix.

2016-07-01 15:31 GMT+02:00 Jacob G <[email protected]>:

> Thanks Lukas! That's exactly the case. In general, we use optimistic
> locking for records that have update contention, and so turn on jooq's
> optimistic locking feature for every table. But this particular table is
> write-once rows, so we don't have a version column for it. So I guess we
> should add per-table checks for it based on whether it truly has a record
> version.
>
>
> On Friday, July 1, 2016 at 9:12:21 AM UTC-4, Lukas Eder wrote:
>>
>> Aha, I see... Can you confirm that:
>>
>> 1. you have turned on the executeWithOptimisticLocking setting
>> 2. this particular table doesn't have any timestamp or version column
>>
>> In that case, I can confirm the issue.
>>
>> Why does this happen?
>>
>> batchStore(), batchDelete() and similar calls execute the respective
>> store(), delete() etc. calls on each individual UpdatableRecord, but with
>> an ExecuteListener that aborts execution (via this QueryCollectorSignal
>> exception) and just collects the SQL query that would have been executed.
>> It then batches these SQL queries, rather than executing them individually.
>> The ExecuteListener is, unfortunately, also applied to the SELECT query
>> that is needed for optimistic locking.
>>
>> The safest solution would probably be to just turn off optimistic locking
>> before we provide a fix. I've registered an issue for this:
>> https://github.com/jOOQ/jOOQ/issues/5383
>>
>> Thanks again for reporting!
>> Lukas
>>
>> 2016-06-30 14:12 GMT+02:00 Jacob G <[email protected]>:
>>
>>> Thanks Lukas for following up.
>>>
>>> We are using Jooq version 3.8.2.
>>>
>>> Here's the code:
>>>
>>> private void deleteRecordsByPk(Collection<R> records) {
>>>
>>>    // Execute a batch DELETE
>>>    if (records.size() > 1) {
>>>       // TODO: Figure out why batch delete is not working.
>>>       // TODO: http://stackoverflow.com/questions/38108847
>>>       dslContext().batchDelete(records).execute();
>>>
>>>       // The following alternative of single-record deletes does work.
>>>       //dslContext().attach(records);
>>>       //records.forEach(UpdatableRecord::delete);
>>>    }
>>>
>>>    // Execute a regular DELETE
>>>    else if (records.size() == 1) {
>>>       dslContext().attach(records);
>>>       records.iterator().next().delete();
>>>    }
>>> }
>>>
>>>
>>> On Thursday, June 30, 2016 at 6:49:15 AM UTC-4, Lukas Eder wrote:
>>>>
>>>> (for the record / for future visitors: this question was also posted on
>>>> Stack Overflow: http://stackoverflow.com/q/38108847/521799)
>>>>
>>>> 2016-06-30 12:48 GMT+02:00 Lukas Eder <[email protected]>:
>>>>
>>>>> Hi Jacob,
>>>>>
>>>>> Thanks for your enquiry. What jOOQ version are you using? And could
>>>>> you please post the Java code that you used to produce this behaviour?
>>>>>
>>>>> Best Regards,
>>>>> Lukas
>>>>>
>>>>> 2016-06-29 21:49 GMT+02:00 Jacob G <[email protected]>:
>>>>>
>>>>>> When I try to do a batch delete, nothing happens. I stepped int other
>>>>>> debugger, and see that BatchCRUD::executeAction calls
>>>>>> UpdatableRecord::delete, and down in the callstack,
>>>>>> UpdatableRecordImpl::checkIfChanged calls fetchOne() which throws a
>>>>>> QueryCollectorSignal. The sql executed works fine in PGAdmin (postgres), 
>>>>>> so
>>>>>> I'm wondering what's going on here? How do I do a proper batch delete?
>>>>>>
>>>>>> --
>>>>>> 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 [email protected].
>>>>>> 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 [email protected].
>>> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to