问题
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
回答1:
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!
回答2:
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/
来源:https://stackoverflow.com/questions/46448249/caused-by-org-hibernate-mappingexception-could-not-determine-type-for-com-fas