0

In my database table, there is a column named json_data, which is a JSON data type field. The according field in the entity class is @Column(name="json_data") String jsonData;.

Some data with UTF-8 characters are saved using entity.save() into database(something like \u2202). When it's retrieved, the encoding is wrong, and I got character \u0113.

My question is: what needs to be done in order to save/retrieve the JSON data type data from MySql using hibernate

Evan_HZY
  • 984
  • 5
  • 17
  • 34
  • 1
    See if this post helps you. http://stackoverflow.com/questions/3682409/reading-utf-8-content-from-mysql-table – vijayanand Jan 05 '17 at 22:06

1 Answers1

0

Try like below:

ObjectMapper objMap=new ObjectMapper();
...
String jsonData = resultSet.getString("json_data");
Employee employee= (Employee) objMap.readValue(jsonData, Employee.class);
//replace Employee with your json java mapper class name
...
rsh
  • 69
  • 4