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.
edit: the Jpa is Spring-Data-Jpa and the JsonNode is fasterxml.jackson
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.
edit: the Jpa is Spring-Data-Jpa and the JsonNode is fasterxml.jackson
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/
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