2016-01-20 93 views
0

CLOB财产我有实体进口同类Maven的依赖,看起来像这样(简体)创建从JSON

@Entity 
public class Person extends Base { 

    private String name; 

    private Clob biography; 
//Getters and setters 

我收到此JSON与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: [email protected]; 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: [email protected]; line: 2, column: 13] (through reference chain: com.example.Person[\"biography\"])", 
    "path": "/persons" 

如果“biography”是String,Person是cre ated。 如何将JSON属性转换为java.sql.Clob属性? 最好的解决方案将调整ObjectMapper,但我很乐意听到任何建议。谢谢!

回答

0

只需使用

@Lob 
String biography 

而在DDL数据库启动列CLOB