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

帅比萌擦擦* 提交于 2021-01-27 18:45:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!