Came across the same issue today, and as jOOQ features no. 5670 
<https://github.com/jOOQ/jOOQ/issues/5670> and 5673 
<https://github.com/jOOQ/jOOQ/issues/5673> seems to keep getting pushed 
back, I implemented a intermediate custom solution (see github 
<https://github.com/sniederb/funneltravel-public/blob/master/funnel-server/src/main/java/ch/want/funnel/services/persistence/jooqextension/CustomDatatypeProcessor.java>).
 
The CustomDatatypeProcessor takes a java.nio.file.Path, reads it and 
converts record data based on the TableRecord -> Fields -> Converter. 
Reusing will need some changes, mainly in the coerce() method, but maybe 
this will help someone who stumbles upon this thread.

Simon

On Friday, November 11, 2016 at 1:01:01 PM UTC+1, Rick Latrine wrote:
>
> Hi,
>
> when I have following field definition in a table:
>
> public final org.jooq.TableField<my.jooq.json.serialize.test.tables.
> records.TestRecord, org.joda.time.DateTime> TIME_UTC
>     = createField("TIME_UTC",
>                   org.jooq.impl.SQLDataType.BIGINT.nullable(false),
>                   this,
>                   null,
>                   new my.jooq.json.serialize.test.converter.
> DateTimeConverter());
>
> With following Converter:
> public class DateTimeConverter implements Converter<Long, DateTime>
>
> formatJson returns the field definition:
> ...
> "fields":[{"name":"TIME_UTC","type":"BIGINT"},
> ...
>
>
> So far so good, as I assumed that jOOQ would use the underlying database 
> type in order to serialize and deserialize the JSON string easily.
>
> But the data part looks like this:
> "2016-06-07T09:00:00.000+02:00"
>
>
> formatJSON converts the custom data type from the fetched record by using 
> toString().
> (see: org.jooq.tools.json.JSONValue#toJSONString in github 
> <https://github.com/jOOQ/jOOQ/blob/version-3.8.0-branch/jOOQ/src/main/java/org/jooq/tools/json/JSONValue.java#L135>
> )
>
> I expected the json serializer would use the converter to get the database 
> type back as a Long value.
> Afterwards the deserializer is not able to turn the String value to BIGINT 
> and renders it to a null value.
>
> My question: is this working as expected, is it a bug or is formatJSON not 
> intended to be used with custom types?
>
> Thanks in advance
> Rick
>
>

-- 
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 jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to