Update jsonb value in PostgreSQL using JOOQ

0

In my Java project I'm usinq JOOQ and I want update JSONB value. But my build failure.

I wrote a code:

DSL.using(connection).update(USER_SETTINGS)
                .set(USER_SETTINGS.SETTING_VALUE, field("{\"filtersValue\":{\"page\":0,\"size\":100}, \"visibleCount\":100}", JSONB.class))
                .where(USER_SETTINGS.USER_ID.eq(98383L))
                .execute();

enter image description here

and I got a next message:

org.jooq.exception.DataAccessException: 
SQL [update "sbcm_sys"."user_settings" set "setting_value" = "filtersValue":{"page":0,"size":100, "visibleCount":100} where "sbcm_sys"."user_settings"."user_id" = ?]; ERROR: syntax err
or at or near ":"
  Position: 71
Caused by: org.postgresql.util.PSQLException: 
ERROR: syntax error at or near ":"
  Position: 71

Where I made a mistake?

java jooq jsonb postgresql
2021-11-22 08:59:51
1

1

You're using DSL.field(String), which is used for plain SQL templating, when you meant to use DSL.val(String), which is used for bind values.

See also this blog post for further clarifications: https://blog.jooq.org/whats-a-string-in-the-jooq-api/

2021-11-22 10:29:00

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................