Jary zhen
Jary zhen

Reputation: 447

Caused by: org.hibernate.MappingException: Could not determine type for: com.fasterxml.jackson.databind.JsonNode

I am trying to use javax.persistence.* to auto create Table by uesing @Entity. Here is some problem. Is there anyway to convert the JsonNode to String By use Annotation.

enter image description here

edit: the Jpa is Spring-Data-Jpa and the JsonNode is fasterxml.jackson

Upvotes: 6

Views: 6025

Answers (3)

bemar
bemar

Reputation: 334

Read this to annotate your column correctly. It's possible to use a json column with hibernate:

https://prateek-ashtikar512.medium.com/how-to-handle-json-in-postgresql-5e2745d5324

Upvotes: 0

Beqir kuci
Beqir kuci

Reputation: 93

You cannot use a JsonNode on entity column using Spring Data Jpa, You must use String and in another class you can write a method which converts string to Json (a reverse Jason to string) format and Resolved!

Upvotes: 2

Jens Schauder
Jens Schauder

Reputation: 81990

Annotate your Json property with @Transient (see https://stackoverflow.com/a/1281957/66686). This will make JPA ignore it.

Have another String property. In the getter and setter transform between String and Json representation.

If you have many properties like this you might want to use an embeddable or if you are using Hibernate a user type (other JPA providers might offer something similar). See this article for an example: https://theodoreyoung.wordpress.com/2012/02/07/custom-user-types-with-jpa-and-spring/

Upvotes: 1

Related Questions