Hello > I couldn't find anything about assigning a PK before INSERT in the > documentation. My scenario: I have a PK generator (don't ask...)
Seems normal to me :) > I need to assign a new PK when a record is inserted and the PK is currently > null. How can I do that? > > My guess is that I could use ExecuteListener for that but which method would > be the best place to assign the PK? So I'm guessing that your generator is implemented in Java and you cannot use triggers to fill in the PK value... What is the reason why you wouldn't implement PK generation in a DAO layer "on top" of jOOQ, supplying the correct PK value to jOOQ? If you really want to do this with jOOQ, ExecuteListener might be a good place to start. You could hook into ExecuteListener.bindStart(). You could then try to patch the bind values of your insert statement with new values, such as a generated PK: http://www.jooq.org/javadoc/latest/org/jooq/ExecuteListener.html#bindStart%28org.jooq.ExecuteContext%29 Another option would be to hook into bindEnd() and replace the bind value directly on the underlying prepared statement: http://www.jooq.org/javadoc/latest/org/jooq/ExecuteListener.html#bindStart%28org.jooq.ExecuteContext%29 These kinds of features will be implemented some day in the jOOQ Console, where bind values can be patched for debugging purposes. So this might indeed be a good place to do that kind of operation. Cheers Lukas
