-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Persisting to Postgres jsonb column broken #36730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The code used to work with 3.2 version of the Quarkus on Java 17 |
Hi @vanuatoo, I started off with a quarkus quickstart for Hibernate ORM with Panache and Rest - https://github.com/quarkusio/quarkus-quickstarts/tree/main/hibernate-orm-rest-data-panache-quickstart - and have it creating a postgres database with entity, but I'm unable to get a working example of adding a jsonb column type (unsure if it's due to Hibernate or due to this bug) Thanks ! |
Here's a draft PR for the quarkus quickstarts showing the commits I made with an example of how to use a JsonB - this works fine on postgres: |
I used a Map<String, Object> and quarkus figured out how to persist that correctly.
When I tried to JsonObject it failed to find a serializer / deserializer for the class, so i would have had to provide a converter as in link, which didn't seem worth the effort when the Map works. @vanuatoo Can you use the Map solution or provide a standalone example that reproduces the problem? |
I used Map and it works fine. |
I would expect this to work with JsonObject itself |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
In order to persist to Postgresql table with the column type of jsonb, I have an JPA Entity defined as
....
@column(name = "payload")
@JdbcTypeCode(SqlTypes.JSON)
public JsonObject eventPayload;
......
I use jakarta.json.JsonObject here.
Expected behavior
When I save the arbitrary payload constructed from the code
Json.createObjectBuilder()
.add("id", 1)
.add("name", "Quarkus")
.build();
I expect that it is stored properly in the database, like
{"id": 1, "name": "Quarkus"}
Actual behavior
The payload is stored like
{"id": {"valueType": "NUMBER"}, "name": {"valueType": "STRING"}}
How to Reproduce?
Output of
uname -a
orver
Darwin EPGETBIW0449 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 arm64
Output of
java -version
openjdk version "21.0.1" 2023-10-17 LTS OpenJDK Runtime Environment Temurin-21.0.1+12 (build 21.0.1+12-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.1+12 (build 21.0.1+12-LTS, mixed mode)
Quarkus version or git rev
3.5.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: