My DDL is the following:

CREATE TABLE user_session
(
  id bigserial NOT NULL,
  id_user integer NOT NULL,
  ...
)


What I was doing was get a custom type of object from a JSON, deserialize 
it and then convert it into a Record. In the conversion step (MyObject --> 
Record) I didn't check for the null value on the PK (which is null when the 
client wants to add a new object to the collection), never realizing that 
by setting the value to null would set the flag of the column to dirty. I 
assumed that the operation was somewhat idempotent under all aspects. Turns 
out I was wrong :).

On Friday, February 15, 2013 11:39:45 AM UTC+1, Lukas Eder wrote:
>
> Hello, 
>
> > TABLERecord r = factoryObj.newRecord(TABLE); 
> > r.set(...); 
> > r.store(); 
> > // r is already updated with the automatically generated ID 
>
> True, that is another (probably better) option 
>
> > I had an error on the primary key being null, probably because I 
> > instantiated a record as a regular Object: new TABLERecord(), and in 
> doing 
> > so the primary key was automatically set to null, leading to the error. 
> > 
> > I hope my mistake will be useful to others. 
>
> Hmm, in general, this should work... So, let's see if it was "your 
> mistake" or a bug. Do you use a serial / auto_increment / sequence 
> with trigger for your primary key? Can you show the table's DDL and 
> the Java code that caused the null-related error? 
>
> 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.


Reply via email to