Hi Sander, That's a feature with several integration tests verifying it! :)
UpdatableRecords always base their actions (store, delete, refresh) on their main unique key (mostly a primary key). If the key value changes, an update wouldn't make sense anymore. Refreshing the record will load a new record. This can be disputed, of course, but jOOQ strongly follows the strategy of maximal normalisation in a database as described in this article, for instance: http://www.techrepublic.com/article/the-great-primary-key-debate/1045050 In that way, changing the primary key value in jOOQ is actually a simple "trick" for duplicating the record. I'll add a ticket to better document this in the UpdatableRecord Javadoc: https://sourceforge.net/apps/trac/jooq/ticket/660 Cheers Lukas Am 23.06.2011 15:03 schrieb "Sander Plas" <[email protected]>: > In jOOQ 1.6.1, changing the value of a primary key field on an > existing record results in a new insert. > > Record from my 'ledger' table, primary key is on column 'code': > > code | description > ------+--------------------------------------- > M1 | test description > > > This works OK: > > record.setDescription("blabla"); > record.store(); > > PostgreSQL log: > > update "public"."ledger" set "description" = $1 where > "public"."ledger"."code" = $2 > parameters: $1 = 'blabla', $2 = 'M1' > > > This doesn't: > > record.setCode("test"); > record.store(); > > PostgreSQL log: > > insert into "public"."ledger" ("code", "description") values ($1, $2) > parameters: $1 = 'test', $2 = 'blabla' > > > Is this a bug or a feature? :)
