Record timestamp field doesn't return updated value after insert

126 views
Skip to first unread message

Venkat Sadasivam

unread,
Jan 3, 2014, 12:10:59 PM1/3/14
to jooq...@googlegroups.com
After inserting new recording the record timestamp field doesn't return updated value.

EmployeeRecord record = new EmployeeRecord();
record.setId(1);
record.update();
System.out.println(record.getStampDate()); // this statement return null whereas in database it inserts with current date/time.

Lukas Eder

unread,
Jan 6, 2014, 3:46:41 AM1/6/14
to jooq...@googlegroups.com
Hi Venkat,

Yes, currently, store() and insert() only refresh the IDENTITY / PRIMARY KEY value from the inserted record. There had been a feature request for loading other, trigger-generated values as well in such records:

We hope that this will make it into jOOQ 3.3.

Cheers
Lukas


2014/1/3 Venkat Sadasivam <venka...@gmail.com>

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Venkat Sadasivam

unread,
Jan 6, 2014, 8:47:30 AM1/6/14
to jooq...@googlegroups.com
Hi Lukas:

Trigger update is different from record timestamp. Record timestamp is been updated by jOOQ (not by database) hence I feel it should reflect in record object without making additional database call.

Regards,
Venkat

Lukas Eder

unread,
Jan 6, 2014, 8:51:26 AM1/6/14
to jooq...@googlegroups.com
Hi Venkat,

You mean the record timestamp as when using jOOQ's optimistic locking feature?

OK then, can you please tell me:

- How does your "new EmployeeRecord()" get a Configuration / Settings prior to the call to update?
- Is Id the primary key?

Regards,
Lukas


2014/1/6 Venkat Sadasivam <venka...@gmail.com>

Venkat Sadasivam

unread,
Jan 6, 2014, 9:33:53 AM1/6/14
to jooq...@googlegroups.com
Hi Lukas:

On the code generator I set timestamp column as below.
database.setRecordTimestampFields("(?i:STAMPDATE)");

On the Settings side, I am not using optimistic locking.
withExecuteWithOptimisticLocking(false))

The insert query updates the database with current date/time whereas the same is not been reflected in the record object.

Regards,
Venkat

Lukas Eder

unread,
Jan 6, 2014, 1:03:37 PM1/6/14
to jooq...@googlegroups.com
Hi Venkat,

Unfortunately, I cannot seem to reproduce this. The relevant integration tests work well for inserts and updates, regardless if the optimistic locking flag is set. Is your Table object generated correctly, i.e. overriding the Table.getRecordTimestamp() method?

I suspect that your regular expression might not match the actual column. The regex is STAMPDATE, the column is generated as getStampDate. That looks as though the database column is in fact STAMP_DATE.

If that's not the case, could you please provide some more information? E.g. the table's DDL, the generated Record class, and the full code needed to reproduce the failing update.

Regards,
Lukas
Reply all
Reply to author
Forward
0 new messages