> You could just throw an exception on PK update.

I'm not so sure about that. The rest of the jOOQ API wouldn't throw
such an exception either. E.g., you could always explicitly update the
PK using Factory.update() or Factory.executeUpdate(), or plain SQL...

> Imagine if the PK has been updated in-between the fetch and store by
> another transaction. Then this could have disastrous behaviour. And it would
> break optimistic locking.

Some databases will create a table lock when you update a primary key.
If not, you should SELECT ... FOR UPDATE such a record, if you intend
to change the primary key.

Anyway, best practices are not relevant for jOOQ (apart from the
Javadoc, maybe), just as they are not relevant for JDBC. "If it's
possible with SQL, it should be possible with jOOQ"...

Cheers
Lukas

Reply via email to