postgresql - Jooq Postgres JSON query -
What is the support for postgradge Jason objects in question with ZEQ?
For example,
SELECT id, data-> 'Author' - & gt; & Gt; From 'first_name' books as author_first_name; Presently (as jOOQ 3.4), there is no native support for those postgresql, JSON's specific JSON operators are pending to support PostgreSQL json
data types. However, you can always use it to help your query be expressed with jOOQ:
DSL.using (configuration). Selection (BOOKS.ID, field ("{0} -> author '-> gt; & gt;' first_name '", string.class, books.data) .as ("author_first_name") .from (books). Fetch ();
For details, see the methods javadocs.
Or, write your own Mini API
If you are using JSON with many of these path notation, you can cause a mini API such as: < / P> Public Stable Fields & lt; Object & gt; JsonObject (field & lt ;? & gt; field, string name) {back to DSL.field ("{0} -> gt; {1}", Object.class, field, DSL.inline (name)); } Public stable field & lt; String & gt; JsonText (field & lt;? & Gt; field, string name) {back to DSL.field ("{0} -> gt; & gt; {1}", string class, field, DSL .line (name) ); }
It can be used as a later version:
DSL.using (configuration) .select (Books.ID, jsonText (JsonObject (BOOKS. Data, "author"), "first_name") .as ("author_first_name")) .from (books) .fetch ();
Comments
Post a Comment