Hi Ben, 2015-04-24 5:47 GMT+02:00 Ben Hood <[email protected]>:
> Hi Lukas, > > I've just updated an app that uses the above mentioned skullduggery to > 3.6.0 and the use of > > void from(Object source) throws MappingException; > > on an UpdateableRecord caused the JOOQ record not to get populated > from the underlying application object. On face value this appears to > be because that application still had @Column annotations on a couple > of fields (this was just cruft). So I nuked the annotations and now > the app works with 3.6.0. > Hmm, but that has always been the case in previous jOOQ implementations, hasn't it? From what version did you upgrade? > That all said, I was wondering whether it is high time that I stopped > using the value tracking facilities from UpdateableRecord and instead > used a SQL builder variant to avoid issuing UPDATE clauses for Java > null values. > > So I was wondering if the JOOQ state of the art has moved on and there > is now a way of using the fluent API to skip null fields of Java > objects? The latest state is this: https://github.com/jOOQ/jOOQ/issues/3582 If your column has a NOT NULL constraint, and your POJO that you pass to Record.from(Object) has a null value, then the Record's internal changed flag for that column will not be set, when you call Record.store(), insert(), or update() This change of behaviour was introduced in jOOQ 3.5. As of jOOQ 3.6, we've also adapted the UPDATE .. SET [ Record ] implementation to consider only those values in a Record that have their changed() flag set to true: https://github.com/jOOQ/jOOQ/issues/4161. Did you try this syntax? DSLContext ctx = DSL.using(configuration); MyTableRecord record = ctx.newRecord(MY_TABLE, pojo); ctx.update(MY_TABLE).set(record).where(...).execute(); Or, did you have something else in mind? Not sure if I've alluded to this previously, but iBatis had > this neat way of building SQL in the thread local so that you could > struct a statement with plain jane Java if statements. > > Is there something like that for JOOQ hipsters? > I'm going to try to translate that lingo to what I think you mean. ;) You're talking about this MyBatis API, right? http://adamgent.com/post/30974973820/mybatis-sqlbuilder-rewritten Let's not discuss the "intriguing" idea of doing this via ThreadLocals but the composability of SQL statements. You can probably do that even better with jOOQ, both with the DSL API, and even more easily with the model API: http://www.jooq.org/doc/latest/manual/sql-building/sql-statements/dsl-and-non-dsl If you can show an example of what you'd like to achieve, I can show you a code example. 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/d/optout.
