Hi Sergei, 2014/1/17 sergivs <[email protected]>
> Hi all, > > I'm just starting to use jOOQ and the first thing that I did was basically > something like this (after creating bindings with the generation tool): > > MyRecord myRecord = dslContext.newRecord(MYTABLE, pojo); > > dslContext.execteInsert(myRecord); > > It's very convenient, but if the POJO does not have a field/getter > method/annotation matching a given field, then the field simply will not be > updated. Is there a way to force the insert/update to fail if a field > cannot be found (other than making the field NOT NULL in the schema, which > would be a hack and wouldn't work for updates, anyway)? > One thing that comes to mind is to implement a RecordListener, which can listen on insertStart() events: http://www.jooq.org/doc/3.2/manual/sql-execution/crud-with-updatablerecords/crud-record-listener/ I'm not sure if I correctly understood your requirements, but if you want to check if any Record field value is NULL prior to executing an insert, that would certainly be an option. > There is a way of handling duplicate keys (update or ignore), as described > here http://blog.jooq.org/tag/on-duplicate-key-update/, but it lacks the > convenience and flexibility of DSLContext.executeInsert(Record). > > Is there a way to insert a record generated from a POJO dynamically as in > my pseudocode above and handle the possible duplicate key? > Record.store() might do what you need. Or did you have something else in mind? 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.
