Код: Выделить всё
create table foo_entity
(
id varchar(255) not null primary key,
jsonb_column jsonb
);
< /code>
Я пытаюсь изменить таблицу, используя собственный запрос через менеджер объектов, как < /p>
EntityManager em; // its obtained somehow
List strings = List.of("foo", "bar");
Query q = em.createNativeQuery("update foo_entity set jsonb_colimn = :value");
q.setParameter("value", new TypedParameterValue(
new JsonBinaryType(new ObjectMapper()),
strings
));
q.executeUpdate();
Код: Выделить всё
2025-07-30T13:53:09.547+03:00 DEBUG 13275 --- [demo1] [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : JDBC exception executing SQL [ update foo_entity set jsonb_column = ?
] [n/a]
org.postgresql.util.PSQLException: ERROR: column "jsonb_column" is of type jsonb but expression is of type bytea
Hint: You will need to rewrite or cast the expression.
Position: 46
< /code>
Между тем, если я предоставлю строковую скаляр в значение, а не в массив, я получаю другую ошибку < /p>
2025-07-30T13:54:57.683+03:00 DEBUG 13526 --- [demo1] [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : JDBC exception executing SQL [ update foo_entity set jsonb_column = ?
] [n/a]
org.postgresql.util.PSQLException: ERROR: column "jsonb_column" is of type jsonb but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 46
Подробнее здесь: https://stackoverflow.com/questions/797 ... binarytype