Java 从JSON创建CLOB属性
我将实体像Maven依赖项一样导入,如下所示(简化) 我通过方法POST收到这个JSONJava 从JSON创建CLOB属性,java,sql,json,spring,clob,Java,Sql,Json,Spring,Clob,我将实体像Maven依赖项一样导入,如下所示(简化) 我通过方法POST收到这个JSON {"name":"John Doe", "biography":"dragonborn"} 我犯了这个错误 "status": 400, "error": "Bad Request", "exception": "org.springframework.http.converter.HttpMessageNotReadableException", "message": "Coul
{"name":"John Doe",
"biography":"dragonborn"}
我犯了这个错误
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.http.converter.HttpMessageNotReadableException",
"message": "Could not read document: Can not construct instance of java.sql.Clob,
problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information\n at
[Source: java.io.PushbackInputStream@39e31d6a; line: 2, column: 13] (through reference chain: com.example.Person[\"biography\"]);
nested exception is com.fasterxml.jackson.databind.JsonMappingException:
Can not construct instance of java.sql.Clob,
problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information\n
at [Source: java.io.PushbackInputStream@39e31d6a; line: 2, column: 13] (through reference chain: com.example.Person[\"biography\"])",
"path": "/persons"
若“传记”是字符串,那个么就创建了人物。
如何将JSON属性转换为java.sql.Clob属性?
最好的解决方案是优化ObjectMapper,但我很乐意听到任何建议。谢谢 只要使用
@Lob
String biography
在DDL for database initiate列中作为CLOB使用
@Lob
String biography
在DDL中,数据库初始化列为CLOB