Hi Ben,

You will find this discussion here inspiring:
https://groups.google.com/d/msg/jooq-user/8MBETRVrLCM/xPeL-COW26QJ

Marko Topolnik has played around with the jOOQ API for a while to find a
suitable solution for a similar problem. Essentially, his solution
resembles yours.

Clearly, there is an additional use-case hidden in there somewhere that
should be better supported by the jOOQ API, i.e. the distinction of the two
possible NULL semantics:

1. Java null = not initialised = SQL "don't touch" = DEFAULT at INSERT,
unchanged at UPDATE
2. Java null = explicit null = SQL NULL both at INSERT and at UPDATE

The problem in differentiating such semantics mostly originates from
transferring DTO / POJO content into an UpdatableRecord, prior to storage.
jOOQ applies semantics 1) when a value was never explicitly set through
UpdatableRecord.setValue(), but semantics 2) when it was explicitly set to
NULL through UpdatableRecord.setValue(). Your workaround using the changed
flag enforces semantics 1)

Another idea was to check for nullability in Field metadata. If a Field is
NOT NULL, then the semantics 2) never makes sense, so people have suggested
to apply semantics 1), then. To me, that seems a bit too clever.

So far, I think your workaround is really the best solution to this
problem, right now...

Cheers
Lukas


2014-05-23 17:58 GMT+02:00 Ben Hood <[email protected]>:

> On Fri, May 23, 2014 at 4:20 PM, Ben Hood <[email protected]> wrote:
> > Admittedly it does use the CRUDy part of JOOQ (it would be nicer if it
> > could just be an option on the plain jane fluent API), but it seems to
> > do the job.
>
> Actually I've decided I don't like this solution much because it
> circumvents the whole type safety thing, which is the main reason to
> use JOOQ in the first place. I wonder if there is a type safe solution
> for this.
>
> --
> 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.
>

-- 
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.

Reply via email to