Hey Anthony,

2016-12-07 23:46 GMT+02:00 Anthony Calce <[email protected]>:
>
>
>    - DSL.val("NOW()")  -> returns a string, type mismatch
>
> That wouldn't work, because DSL.val() creates a bind variable, not an
expression. In this case, the value would be the string 'NOW()', instead of
the function call NOW().

>
>    - DSL.field("NOW()", DateTime.class) -> returns a Field<DateTime>
>    which isn't compatible
>
> That's close, but you cannot do it this way, because jOOQ doesn't know
what Joda's DateTime means. (It would work with JSR 310 LocalDateTime). You
have to provide jOOQ with the actual DataType that contains your converter.
There are several ways to do it:

1) Create the DataType afresh using
SQLDataType.TIMESTAMP.asConvertedDataType(YOUR_DATE_TIME_CONVERTER)
2) Recycle the existing DataType on the inserted column:
CUSTOMER.CANCEL_DATE.getDataType()

And then:

DSL.field("NOW()", theDateTimeDataType);

Your workaround works, because of some internal type coercion in the INSERT
statement, when you bypass type safety.

Samir's suggestion (DSL.currentTimestamp()) will also work (if you bypass
type safety with a Collection) because of that same type coercion, but it
will return the CURRENT_TIMESTAMP() function, which is very subtly
different from NOW() in MySQL.

Hope this helps,
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.

Reply via email to