Thank you Lukas.
Now I should be able to proceed on my own.

Il giorno mercoledì 3 dicembre 2014 10:14:10 UTC+1, Lukas Eder ha scritto:
>
> Hi Luca,
>
> Thanks for your enquiry. PostgreSQL's various advanced data types are 
> precisely the reason why we implemented the new Binding<T, U> type in jOOQ 
> 3.5. Right now, users will have to implement their own bindings. The only 
> binding we're offering out of the box with jOOQ 3.5 is the one that 
> implements Oracle's "DATE as TIMESTAMP" semantics. We'll improve this in 
> the future, probably via a commercial extension that we maintain (also for 
> HSTORE, PostGIS, Range types, and much more) as writing all these bindings 
> will be rather tedious. But we'd like to keep them out of the core 
> deliverable, as such bindings really aren't reusable at all among databases 
> - besides, we don't want to impose Jackson, Gson, or JSR 353 as a Java/JSON 
> API.
>
> The best way for you to go forward is indeed to implement such a binding 
> and configure your code generator to bind it. A full example can be seen 
> here:
>
> http://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings/
>
> I've also repeated this example here on Stack Overflow:
> http://stackoverflow.com/q/27044702/521799
>
> The example binds a serialised JSON string, but explicitly casts it to the 
> PostgreSQL "JSON" type.
>
> Hope this helps,
> Lukas
>
> 2014-12-03 10:04 GMT+01:00 Luca Veronese <[email protected] 
> <javascript:>>:
>
>> Hi Lukas,
>>
>> I'm trying to execute an INSERT statement like this:
>>
>> create.insertInto(DOCUMENTS, DOCUMENTS.DOC_TYPE,
>> DOCUMENTS.DOC_ID, DOCUMENTS.DOC_LAST_LN,
>> DOCUMENTS.DOC_PAYLOAD)
>> .values("SCHEMA", schemaId, 0, jsonSchema).execute();
>>
>> jsonSchema is a String. DOC_PAYLOAD is a PostgreSQL JSON datatype.
>>
>> Unfortunately Postgres JSON datatype has no implicit cast from varchar or 
>> text.
>> This means in my code passing a String to JOOQ insertInto statement fails.
>>
>> I assume I have these possible solutions:
>> - using straight sql to pass an insert statement that performs a CAST to 
>> JSON;
>> - implement a Binding<T,U> for binding Strings to Postgres JSON (did not 
>> found any example on how to do this in the doc);
>> - changing the Postgres column to text and losing json operators in the 
>> database;
>> - hacking Postgres adding a CAST definition from varchar/text to json;
>>
>> Do you have any suggestion about implementing Binding<T,U> or the 
>> preferred approach?
>> Is there anyone who has already implemented Binding<T,U> for PostgreSQL 
>> JSON datatype?
>>
>> Thank you in advance for your time.
>> Luca
>>
>

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