Hibernate Reactive with Panache can't insert into a jsonb column
See original GitHub issueDescribe the bug
I’m using Quarkus Hibernate Types to map some attributes of my entity to PostgresSQL’s jsonb
column type.
If I use the regular JDBC driver, it works normally.
However, when using Hibernate Reactive, querying works, but inserting new entities fail with the error:
{"details":"Error id 3c00e4fb-6fc9-4953-9594-0410fa4c9093-1, io.vertx.core.impl.NoStackTraceThrowable: Parameter at position[0] with class = [com.fasterxml.jackson.databind.node.ObjectNode] and value = [{\"field\":\"value\"}] can not be coerced to the expected class = [java.lang.Object] for encoding.","stack":"io.vertx.core.impl.NoStackTraceThrowable: Parameter at position[0] with class = [com.fasterxml.jackson.databind.node.ObjectNode] and value = [{\"field\":\"value\"}] can not be coerced to the expected class = [java.lang.Object] for encoding."}
Expected behavior
It should insert the entity with no error.
Actual behavior
The entity is not inserted and an error occurs.
How to Reproduce?
- Clone this repo
- Run
docker-compose up
to start the db - Run
./mvnw quarkus:dev
to start the app - Run the following curl to try to insert data:
curl -X POST -H 'Content-Type: application/json' -i http://localhost:8080/example --data '{
"id": 3,
"content": { "yetAnotherField": "yetAnotherValue" }
}'
If you run curl -X GET -i http://localhost:8080/example
, it works perfectly.
Output of uname -a
or ver
Microsoft Windows [version 10.0.19043.1288]
Output of java -version
java version “11.0.12” 2021-07-20 LTS Java™ SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237) Java HotSpot™ 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.4.1.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Additional information
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:17 (12 by maintainers)
Top Results From Across the Web
Simplified Hibernate ORM with Panache - Quarkus
The solution is located in the hibernate-orm-panache-quickstart directory. If your project is already configured to use other annotation processors, you will ...
Read more >Using the PostgreSQL JSONB type with Hibernate Reactive
I am migrating my Quarkus project from the classic Hibernate ORM to Hibernate Reactive and I faced a problem with JSONB field mapping....
Read more >How to use PostgreSQL's JSONB data type with Hibernate
PostgreSQL offers proprietary datatypes to store JSON documents which are not supported by Hibernate. But you can change that with a UserType.
Read more >Postgres JSONB type and Hibernate Panache - Google Groups
I'm considering using JSON capabilities from PostgreSQL , using JSONB field type. I've found this library from Vlad : https://github.com/ ...
Read more >Batch Insert/Update with Hibernate/JPA - Baeldung
When we want to use batching for inserts, we should be aware of the primary key generation strategy. If our entities use the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve created this issue on Hibernate Reactive: https://github.com/hibernate/hibernate-reactive/issues/1180 Maybe we can do something for making this easier to handle
Thanks for your feedback! It was really helpful