2

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?

1
  • I changed field() to val() and it's work! Commented Nov 22, 2021 at 10:33

1 Answer 1

2

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.