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

Viewed 3125

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

3 Answers

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!

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/

Related