I have a localizable/unicode JSON column on a MySQL database which is accessed via JPA. I get garbled up unicode strings on my API response
{
"bannerTitle": "Copyright © 2019",
}
The JSON binds to following entity property
@Column(nullable = false, columnDefinition = "json")
private String settings;
My data source URL has the Unicode tags as follows
jdbc:mysql://localhost:3306/mydb?characterEncoding=utf-8&useUnicode=yes
I tried using a converter in the following lines
public class StringToByteConverter implements AttributeConverter<String, byte[]>
which fixed my fetch queries, but my save queries crashed with
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
What is the right way to fix while using the JPA persistence libraries?
OS: Ubuntu 18.04
MySQL: 5.7.27
Java: openjdk version "1.8.0_222"
Spring boot : 1.5.6.RELEASE