Hi Francesco, > I am using the generated POJOs and DAOs to retrieve and store objects in my > database. I know that, for "regular" INSERTs, I can use the returning() > method, but how can I retrieve the inserted object? There is a sequence for > the ID, which is automatically generated by the database and I would like to > get back. > I would like to know if I can avoid using DAOs and do a simple > factory.insert(TABLE, TABLERecord) so I can use the returning() right there.
Yes you can. I've just noticed that the API for such operations is a bit clumsy, though. You'll have to resort to using jOOQ's internal model (a.k.a. non-DSL API, classic API, model API) for that. Here's an example: TableRecord record = // ... your record InsertQuery<TableRecord> insert = factory.insertQuery(TABLE); insert.addRecord(record); insert.setReturning(); insert.execute(); TableRecord result = insert.getReturnedRecord(); Inserting (and updating) pre-existing Records through the DSL API should be possible, though. I've added feature request #2199 for this: https://github.com/jOOQ/jOOQ/issues/2199 Cheers Lukas -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
