2016-01-20 2 views
0

У меня есть Entity импортирован как зависимость Maven, выглядит следующим образом (упрощенный)Создать CLOB свойство из 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" 

Если «биография» была строкой, ованные. Как я могу преобразовать свойство JSON в свойство java.sql.Clob? Лучшее решение будет настраивать ObjectMapper, но я был бы рад услышать любые советы. Благодаря!

ответ

0

Просто используйте

@Lob 
String biography 

И в DDL для базы данных инициируют столбец как CLOB

Смежные вопросы