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();
Thanks
Aym
On Friday, November 1, 2013 10:46:31 PM UTC+8, Lukas Eder wrote:
>
> Hi Aym,
>
> 2013/10/30 <[email protected] <javascript:>>
>
>> 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.