Hello Sander, Thanks for reporting that issue about risking race conditions or other inconsistencies with lastID() for Postgres: https://sourceforge.net/apps/trac/jooq/ticket/802
This reminds me of another task that has been on the roadmap for a while: http://sourceforge.net/apps/trac/jooq/ticket/558 MySQL supports an INSERT ... ON DUPLICATE KEY UPDATE ... clause, which is a very convenient short-cut for the SQL standard MERGE statement. Both statements are supported since jOOQ 1.6.0 In those five dialects that support the MERGE statement (DB2, HSQLDB, Oracle, SQL Server, Sybase), the ON DUPLICATE KEY UPDATE clause can be supported "natively". In other dialects, simulation might be possible by running a SELECT followed by an INSERT / UPDATE, or by running an INSERT followed by an UPDATE on exception. These simulations will cause the same issues as you have experienced with lastID(). If not properly wrapped in transactions, race conditions can occur, and in the SELECT -> INSERT / UPDATE case, even deadlocks. Do you have any experience / ideas with this sort of statement / processing in Postgres? That might be very useful for other users, too Cheers Lukas
