从JSON创建CLOB属性 [英] Create CLOB property from JSON
本文介绍了从JSON创建CLOB属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将实体导入为Maven依赖项,看起来像这样(简化)
I have Entity imported like a Maven dependency, looks like this(simplified)
@Entity
public class Person extends Base {
private String name;
private Clob biography;
//Getters and setters
我使用POST方法接收此JSON
And I receive this JSON with method POST
{"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"
如果传记是字符串,则创建Person。
如何将JSON属性转换为java.sql.Clob属性?
最佳的解决方案是调整ObjectMapper,但我很乐意听到任何建议。
If "biography" was String, Person is created. How can i convert JSON property to java.sql.Clob property? The best solution will tuning ObjectMapper, but i would be glad to hear any advices. Thanks!
推荐答案
只用
@Lob
String biography
在DDL中,数据库启动列为CLOB
And in DDL for database initiate column as CLOB
这篇关于从JSON创建CLOB属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文