https://github.com/jOOQ/jOOQ/issues/15115 (an improved error message and 
javadoc on the DataChangedException) has been implemented for 3.19.0, 
3.18.5, 3.17.14, 3.16.20

On Saturday, May 27, 2023 at 8:58:39 AM UTC+2 simon.ma...@gmail.com wrote:

> Hi Lukas,
>
> Thanks for the explanation.
> Yes, I think a more expressive error message would be helpful.
>
> Thanks, Simon
>
> On Wednesday, May 24, 2023 at 2:22:52 PM UTC+2 lukas...@gmail.com wrote:
>
>> ... on second thought, I don't think we should ignore the feature and 
>> store the record silently. Much rather, a different error message ("can't 
>> lock this particular record") would help explain the problem.
>>
>> On Wed, May 24, 2023 at 2:21 PM Lukas Eder <lukas...@gmail.com> wrote:
>>
>>> Thanks for your patience. I've had a look at this issue and created a 
>>> ticket here with some more details:
>>> https://github.com/jOOQ/jOOQ/issues/15115
>>>
>>> I don't think jOOQ can do much about this case. jOOQ doesn't know which 
>>> fields you've changed in your POJO (rental.setRentalDate()) and which 
>>> fields have been changed in the database, because unlike the 
>>> UpdatableRecord, the POJO doesn't keep any dirty flags. That's the point of 
>>> the POJO types. However, there might be an argument in favour of ignoring 
>>> the optimistic locking feature when:
>>>
>>> - An UpdatableRecord was not "fetched" (i.e. created entirely in the 
>>> client, e.g. from a POJO as in your case)
>>> - When we're using unversioned optimistic locking (because with 
>>> versioned rows, this problem wouldn't happen)
>>>
>>> Thoughts?
>>>
>>> On Wed, May 17, 2023 at 5:27 PM Lukas Eder <lukas...@gmail.com> wrote:
>>>
>>>> Thanks, I will, soon
>>>>
>>>> On Wed, May 17, 2023 at 5:06 PM Simon Martinelli <simon.ma...@gmail.com> 
>>>> wrote:
>>>>
>>>>> I didn't configure any column so it should use all columns.
>>>>>
>>>>> You can try it yourself: https://github.com/simasch/jooq-workshop
>>>>> (Make sure Docker is running locally)
>>>>>
>>>>> That's the test that causes the problem:
>>>>>
>>>>> https://github.com/simasch/jooq-workshop/blob/main/jooq-sakila/src/test/java/ch/martinelli/edu/jooq/sakila/exercise/Ex06DaosTest.java
>>>>>
>>>>> On Wednesday, May 17, 2023 at 4:53:50 PM UTC+2 lukas...@gmail.com 
>>>>> wrote:
>>>>>
>>>>>> Hi Simon,
>>>>>>
>>>>>> What column(s) did you configure for your optimistic locking checks? 
>>>>>> What SQL queries are being generated in your debug logs?
>>>>>>
>>>>>> Best Regards,
>>>>>> Lukas
>>>>>>
>>>>>> On Wed, May 17, 2023 at 4:39 PM Simon Martinelli <
>>>>>> simon.ma...@gmail.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I've configured optimistic locking:
>>>>>>>
>>>>>>> @Configuration
>>>>>>> public class SakilaJooqConfiguration {
>>>>>>>
>>>>>>> @Bean
>>>>>>> public DefaultConfigurationCustomizer configurationCustomizer() {
>>>>>>>     return (DefaultConfiguration c) -> c.settings()
>>>>>>>         .withExecuteWithOptimisticLocking(true);
>>>>>>>     }
>>>>>>> }
>>>>>>>
>>>>>>> Now I try to use a DAO with a POJO to read and update:
>>>>>>>
>>>>>>> var rentalDao = new RentalDao(dsl.configuration());
>>>>>>>
>>>>>>> rentalDao.findOptionalById(854L).ifPresent(rental -> {
>>>>>>>     rental.setRentalDate(LocalDateTime.now());
>>>>>>>     rentalDao.update(rental);
>>>>>>> });
>>>>>>>
>>>>>>> But this leads to 
>>>>>>>
>>>>>>>
>>>>>>> org.jooq.exception.DataChangedException: Database record has been 
>>>>>>> changed
>>>>>>>
>>>>>>> at 
>>>>>>> org.jooq.impl.UpdatableRecordImpl.checkIfChanged(UpdatableRecordImpl.java:507)
>>>>>>> at 
>>>>>>> org.jooq.impl.UpdatableRecordImpl.storeMergeOrUpdate0(UpdatableRecordImpl.java:345)
>>>>>>> at 
>>>>>>> org.jooq.impl.UpdatableRecordImpl.storeUpdate0(UpdatableRecordImpl.java:240)
>>>>>>> at 
>>>>>>> org.jooq.impl.UpdatableRecordImpl.lambda$storeUpdate$1(UpdatableRecordImpl.java:232)
>>>>>>> at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:144)
>>>>>>> at 
>>>>>>> org.jooq.impl.UpdatableRecordImpl.storeUpdate(UpdatableRecordImpl.java:231)
>>>>>>> at 
>>>>>>> org.jooq.impl.UpdatableRecordImpl.update(UpdatableRecordImpl.java:168)
>>>>>>> at 
>>>>>>> org.jooq.impl.UpdatableRecordImpl.update(UpdatableRecordImpl.java:163)
>>>>>>> at org.jooq.impl.DAOImpl.update(DAOImpl.java:210)
>>>>>>> at org.jooq.impl.DAOImpl.update(DAOImpl.java:186)
>>>>>>>
>>>>>>> When I debug into UpdatableRecordImpl I see that in the record only 
>>>>>>> the id is set.
>>>>>>>
>>>>>>> Is this a bug or did I miss somehting?
>>>>>>>
>>>>>>> Thanks, 
>>>>>>> Simon
>>>>>>>
>>>>>>> -- 
>>>>>>> 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+...@googlegroups.com.
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/jooq-user/b734e1bf-0121-47a2-be39-196b0cd8b1e5n%40googlegroups.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/jooq-user/b734e1bf-0121-47a2-be39-196b0cd8b1e5n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> -- 
>>>>> 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+...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/jooq-user/e5aca150-0b82-4618-8de9-d8d50092742fn%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/jooq-user/e5aca150-0b82-4618-8de9-d8d50092742fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>

-- 
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/fefcd73a-1556-483e-9828-7bd0c40535b9n%40googlegroups.com.

Reply via email to