I've managed to reproduce this issue only with PostgreSQL, so far.
This issue is fixed for jOOQ 3.3.0.
https://github.com/jOOQ/jOOQ/commit/8875940e9d4ba5846ffaae6ce8735240ba62af09

The fix will be merged to jOOQ 3.2.2

Cheers
Lukas

2013/11/10 Lukas Eder <[email protected]>

> Hello,
>
> I'm sorry for the delay. I've been presenting jOOQ at the Topconf in
> Tallinn, so a couple of E-Mails have been piling up.
>
> 2013/11/4 <[email protected]>
>
> Thanks for the reply,
>>
>> Here we go:
>>
>> public void foobar(){
>>    DSLContext create = DSL.using(datasource, SQLDialect.POSTGRES);
>>    MovieRecord record =
>> create.newRecord(org.company.commons.jooq.tables.Movie.MOVIE);
>>    record.setTitle("Gravity");
>>    record.setLang("English");
>>    create.executeInsert(record);
>> }
>>
>> gives me "Caused by: org.postgresql.util.PSQLException: ERROR: null value
>> in column "id" violates not-null constraint" exception. Movie got an auto
>> incremental 'id' column
>> Tried "record.changed(false);" but no avail.
>>
>> But
>> public void foobar1(){
>>    DSLContext create = DSL.using(datasource, SQLDialect.POSTGRES);
>>    MovieRecord record =
>> create.newRecord(org.company.commons.jooq.tables.Movie.MOVIE);
>>    record.setTitle("Gravity");
>>    record.setLang("English");
>>    record.attach(create.configuration());
>>    record.store();
>>    record.detach();
>> }
>>
>> *(absolutely no other code change anywhere else)*
>>
>> works perfectly and I can get the generated id via record.getId();
>>
>
> I see, thank you for the examples. Yes, there has been a bit of confusion
> recently, about how to handle "null" values when inserting records. In this
> example, clearly, executeInsert() is behaving wrong as it should not
> explicitly set the null value unless the changed flag is set to true.
>
> I have registered https://github.com/jOOQ/jOOQ/issues/2835 for this.
> Thanks for reporting
>
> Cheers
> Lukas
>
>
>> Thanks
>> Aym
>>
>> On Friday, November 1, 2013 10:46:31 PM UTC+8, Lukas Eder wrote:
>>>
>>> Hi Aym,
>>>
>>> 2013/10/30 <[email protected]>
>>>
>>> Hi,
>>>>
>>>> Just started playing with Jooq, looks really good!.
>>>>
>>>
>>> Thanks for the feedback!
>>>
>>>
>>>> One question though, I'm trying to insert a movieRecord to table with
>>>> id (autogenerated) using DSLContext().executeInsert().
>>>> But it throws exception "Caused by: org.postgresql.util.PSQLException:
>>>> ERROR: null value in column "id" violates not-null constraint"
>>>>
>>>> But if I attach configuration to movieRecord and fire
>>>> movieRecord.store() it works.
>>>>
>>>> Any reason why executeInsert() behaves differently?
>>>>
>>>
>>>  There has been some confusion recently around this subject with respect
>>> to jOOQ's handling NULL values and the changed flag. Most of it was
>>> discussed in this interesting thread:
>>> https://groups.google.com/d/msg/jooq-user/8MBETRVrLCM/oAt9hbE6kY4J
>>>
>>> Can you provide some code showing how to produce the error with
>>> executeInsert() ? I don't think that should happen, unless you actually set
>>> the ID value to NULL.
>>>
>>> Cheers
>>> Lukas
>>>
>>  --
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.

Reply via email to