question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hibernate Reactive with Panache can't insert into a jsonb column

See original GitHub issue

Describe 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?

  1. Clone this repo
  2. Run docker-compose up to start the db
  3. Run ./mvnw quarkus:dev to start the app
  4. 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
DavideDcommented, Feb 4, 2022

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

1reaction
DavideDcommented, Feb 3, 2022

Thanks for your feedback! It was really helpful

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found