jOOQ - dao - primary key of inserted object
java, jooq, sql
Solution
This is a missing feature in jOOQ 3.5 and is tracked as two independent feature requests:
- #2536 - In DaoImpl set the Id of the inserted pojo
- #3021 - Add DAO.insertAndFetch() to return the updated POJO from the database
Right now, you cannot fetch generated keys on insert unless you implement your own `insert()` method, or extend the code generator to generate that method for you.
Problem
I am using the DAO's as generated by jOOQ: ``` <generate> <relations>true</relations> <records>true</records> <pojos>true</pojos> <daos>true</daos> <interfaces>true</interfaces> <globalObjectReferences>true</globalObjectReferences> <jpaAnnotations>true</jpaAnnotations> <validationAnnotations>true</validationAnnotations> <fluentSetters>true</fluentSetters> </generate> ``` After inserting a POJO to the database, how do I get the created identifier/primary key? The insertion succeeds, but calling `getIdentifier()` on the POJO still returns `null`.