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
2014-11-28 11:55 GMT+01:00 Luca Veronese <[email protected]>:
> Hi Lukas,
>
> Tomcat 7 has an annotations-api.jar and this has the bug.
>
> 2014-11-28 11:09 GMT+01:00 Lukas Eder <[email protected]>:
>
>> Hi Luca,
>>
>>
>>
>> That is very curious and should probably reported as a bug to Tomcat. Why
>> would they have introduced an erroneous class for JDK standard API…?
>>
>>
>>
>> Good luck with your JSON / PostgreSQL integration attempts. Again, if you
>> have any specific questions, just shout.
>>
>>
>>
>> Cheers,
>>
>> Lukas
>>
>>
>>
>> *From:* Luca Veronese [mailto:[email protected]]
>> *Sent:* Mittwoch, 26. November 2014 19:40
>> *To:* Lukas Eder
>> *Subject:* Re: JOOQ 3.5.0 problems
>>
>>
>>
>> Hi Lukas,
>>
>>
>>
>> I found the source of the annotation problem.
>>
>> Seems the annotations library shipped with tomcat 7 has a different
>> implementation for the same annotation (comment instead of comments).
>>
>> For some reason tomcat libraries were picked first and this caused the
>> problem.
>>
>> Reordering library dependencies fixed everything.
>>
>> My apologies for having doubted of JOOQ... ;-)
>>
>>
>>
>> I will continue my tests in the next days. Hope JOOQ accepts a String for
>> JSON in Postgres...
>>
>>
>>
>> Best Regards,
>>
>> Luca
>>
>>
>>
>> 2014-11-26 14:24 GMT+01:00 Luca Veronese <[email protected]
>> >:
>>
>> Hi Lukas,
>>
>>
>>
>> I installed Oracle Java 8 SDK this morning.
>>
>> Since this is a new project I want to take advantage of lambdas and
>> streams.
>>
>>
>>
>> java version "1.8.0_25"
>>
>> Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
>>
>> Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
>>
>>
>>
>> I had to correct comments to comment in order to have the code compiled.
>>
>> Maybe it was my fault but I can't find where I was wrong.
>>
>>
>>
>> Best Regards,
>>
>> Luca
>>
>>
>>
>> 2014-11-26 14:19 GMT+01:00 Lukas Eder <[email protected]>:
>>
>> Hello Luca,
>>
>>
>>
>> Thank you very much for your interest in jOOQ and for your feedback and
>> nice words.
>>
>>
>>
>>
>>
>>
>>
>> *@Generated annotation*
>>
>>
>>
>> The @Generated annotation seems to be correct. The property is really
>> called “comments” (plural, with an “s”):
>>
>>
>> http://docs.oracle.com/javase/8/docs/api/javax/annotation/Generated.html#comments--
>>
>>
>>
>> We cover these things with extensive integration tests, so it would
>> indeed be surprising if we had missed this issue.
>>
>> What kind of JDK distribution are you using at your side?
>>
>>
>>
>> In any case, you can deactivate that annotation if you cannot get it to
>> run with your specific JDK. The flag is called <generatedAnnotation/>:
>>
>> http://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/
>>
>>
>>
>> *JSON data type*
>>
>>
>>
>> Regarding the missing JSON data type support, with jOOQ 3.5, we’ve
>> finally implemented a thorough solution that allows access to all
>> vendor-specific data types. An example using Gson can be seen here:
>>
>>
>> http://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings/
>>
>>
>>
>> Another example using Jackson can be seen here:
>>
>> http://stackoverflow.com/q/27044702/521799
>>
>>
>>
>> We’ve decided not to support all of these data types (also HSTORE,
>> Geometry and many other PostGIS types, etc.) out of the box, but to allow
>> users and database vendors to implement their own bindings directly. This
>> will make jOOQ much more robust for the future.
>>
>>
>>
>>
>>
>>
>>
>> I hope I could help you with my answers today. Should you have any
>> further questions, please do not hesitate to ask. We also monitor the jOOQ
>> User Group (https://groups.google.com/d/forum/jooq-user) or Stack
>> Overflow very closely, should you choose to put your questions there.
>>
>>
>>
>> Best Regards,
>>
>> Lukas
>>
>>
>>
>>
>>
>> Lukas Eder – Founder and CEO | [email protected] | +41 44 586
>> 82 56 <+41%2044%20586%2082%2056>
>>
>> Data Geekery GmbH | Binzstrasse 23 | CH-8045 Zürich | Switzerland
>>
>>
>>
>> http://www.datageekery.com | Get back in control of your SQL™
>>
>>
>>
>> [image:
>> http://www.jooq.org/img/jooq-the-best-way-to-write-sql-in-java-small.png]
>>
>>
>>
>>
>>
>>
>>
>> *From:* Luca Veronese [mailto:[email protected]]
>> *Sent:* Mittwoch, 26. November 2014 13:13
>> *To:* Contact
>> *Subject:* JOOQ 3.5.0 problems
>>
>>
>>
>> Hi,
>>
>>
>>
>> I've just downloaded JOOQ to try it for the first time.
>>
>> I generated a schema for a PostgreSQL 9.3 database but I found two
>> problems.
>>
>>
>>
>> The first, really annoying, is that the generated code does not compile.
>>
>> All of these annotations give an error:
>>
>>
>>
>> @javax.annotation.Generated(
>>
>> value = {
>>
>> "http://www.jooq.org",
>>
>> "jOOQ version:3.5.0"
>>
>> },
>>
>> comments = "This class is generated by jOOQ"
>>
>> )
>>
>>
>>
>> The problem seems to be the comments keyword that should be comment I
>> presume.
>>
>> Modifying all of them into comment had the code compile successfully.
>>
>> Finding such an easy bug to spot and fix seems a bit weird to me anyway...
>>
>>
>>
>> The second problem is that JOOQ seems not support the PostgreSQL JSON
>> datatype.
>>
>> I've not tried to insert rows with the generated code but I see it treats
>> the column as an Object.
>>
>> Maybe it's better to make it into a String in this case?
>>
>>
>>
>> JOOQ seems an awesome product and I want to study it very well.
>>
>> I'm probably going to build a set of database oriented development and
>> management tools on top of it.
>>
>> But I'm currently getting my feet wet.
>>
>>
>>
>> Thank you for your valuable time.
>>
>>
>>
>> --
>>
>>
>> Luca Veronese
>> Tabula srls
>> via Angeli, 47
>> 45100 Rovigo (RO)
>> Mobile: 348 1211282
>>
>> email: [email protected]
>>
>> skype: luca.veronese.ro
>>
>> twitter: lveronese65
>>
>> ***********************************************************************
>> NOTICE: This e-mail transmission, and any documents, files or previous
>> e-mail messages attached to it, may contain confidential or privileged
>> information. If you are not the intended recipient, or a person
>> responsible for delivering it to the intended recipient, you are
>> hereby notified that any disclosure, copying, distribution or use of
>> any of the information contained in or attached to this message is
>> STRICTLY PROHIBITED. If you have received this transmission in error,
>> please immediately notify the sender and delete the e-mail and attached
>> documents. Thank you.
>> ***********************************************************************
>>
>>
>>
>>
>>
>> --
>>
>>
>> Luca Veronese
>> Tabula srls
>> via Angeli, 47
>> 45100 Rovigo (RO)
>> Mobile: 348 1211282
>>
>> email: [email protected]
>>
>> skype: luca.veronese.ro
>>
>> twitter: lveronese65
>>
>> ***********************************************************************
>> NOTICE: This e-mail transmission, and any documents, files or previous
>> e-mail messages attached to it, may contain confidential or privileged
>> information. If you are not the intended recipient, or a person
>> responsible for delivering it to the intended recipient, you are
>> hereby notified that any disclosure, copying, distribution or use of
>> any of the information contained in or attached to this message is
>> STRICTLY PROHIBITED. If you have received this transmission in error,
>> please immediately notify the sender and delete the e-mail and attached
>> documents. Thank you.
>> ***********************************************************************
>>
>>
>>
>>
>>
>> --
>>
>>
>> Luca Veronese
>> Tabula srls
>> via Angeli, 47
>> 45100 Rovigo (RO)
>> Mobile: 348 1211282
>>
>> email: [email protected]
>>
>> skype: luca.veronese.ro
>>
>> twitter: lveronese65
>>
>> ***********************************************************************
>> NOTICE: This e-mail transmission, and any documents, files or previous
>> e-mail messages attached to it, may contain confidential or privileged
>> information. If you are not the intended recipient, or a person
>> responsible for delivering it to the intended recipient, you are
>> hereby notified that any disclosure, copying, distribution or use of
>> any of the information contained in or attached to this message is
>> STRICTLY PROHIBITED. If you have received this transmission in error,
>> please immediately notify the sender and delete the e-mail and attached
>> documents. Thank you.
>> ***********************************************************************
>>
>
>
>
> --
>
> Luca Veronese
> Tabula srls
> via Angeli, 47
> 45100 Rovigo (RO)
> Mobile: 348 1211282
> email: [email protected]
> skype: luca.veronese.ro
> twitter: lveronese65
>
> ***********************************************************************
> NOTICE: This e-mail transmission, and any documents, files or previous
> e-mail messages attached to it, may contain confidential or privileged
> information. If you are not the intended recipient, or a person
> responsible for delivering it to the intended recipient, you are
> hereby notified that any disclosure, copying, distribution or use of
> any of the information contained in or attached to this message is
> STRICTLY PROHIBITED. If you have received this transmission in error,
> please immediately notify the sender and delete the e-mail and attached
> documents. Thank you.
> ***********************************************************************
>
>
--
Luca Veronese
Tabula srls
via Angeli, 47
45100 Rovigo (RO)
Mobile: 348 1211282
email: [email protected]
skype: luca.veronese.ro
twitter: lveronese65
***********************************************************************
NOTICE: This e-mail transmission, and any documents, files or previous
e-mail messages attached to it, may contain confidential or privileged
information. If you are not the intended recipient, or a person
responsible for delivering it to the intended recipient, you are
hereby notified that any disclosure, copying, distribution or use of
any of the information contained in or attached to this message is
STRICTLY PROHIBITED. If you have received this transmission in error,
please immediately notify the sender and delete the e-mail and attached
documents. Thank you.
***********************************************************************
--
Luca Veronese
Tabula srls
via Angeli, 47
45100 Rovigo (RO)
Mobile: 348 1211282
email: [email protected]
skype: luca.veronese.ro
twitter: lveronese65
***********************************************************************
NOTICE: This e-mail transmission, and any documents, files or previous
e-mail messages attached to it, may contain confidential or privileged
information. If you are not the intended recipient, or a person
responsible for delivering it to the intended recipient, you are
hereby notified that any disclosure, copying, distribution or use of
any of the information contained in or attached to this message is
STRICTLY PROHIBITED. If you have received this transmission in error,
please immediately notify the sender and delete the e-mail and attached
documents. Thank you.
***********************************************************************
--
Luca Veronese
Tabula srls
via Angeli, 47
45100 Rovigo (RO)
Mobile: 348 1211282
email: [email protected]
skype: luca.veronese.ro
twitter: lveronese65
***********************************************************************
NOTICE: This e-mail transmission, and any documents, files or previous
e-mail messages attached to it, may contain confidential or privileged
information. If you are not the intended recipient, or a person
responsible for delivering it to the intended recipient, you are
hereby notified that any disclosure, copying, distribution or use of
any of the information contained in or attached to this message is
STRICTLY PROHIBITED. If you have received this transmission in error,
please immediately notify the sender and delete the e-mail and attached
documents. Thank you.
***********************************************************************
--
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.