对于Hibernate类型的扩展,我使用vladmihalcea / hibernate-types
@Entity
@TypeDef (
name = "jsonb-node",
typeClass = JsonStringType.class
)
public class Catalog {
...
@Type (type = "jsonb-node")
@Column (columnDefinition = "json")
public ArrayNode tags;
}
将JSON对象从MySQL转换为ArrayNode时,UTF8字符未正确转换
List <Catalog> catalog = em.createNativeQuery (
"select *"
+ "from Catalog c"
+ "where name regexp ('" + nameRegExpr + "*')"
+ "and isTemplate = true"
, Catalog.class
)
.getResultList ();
结果,我得到了以下形式的字符串 {“ key”:“ ??????????”}
字符串的字节 7B226B6579223A223F3F3F3F3F3F3F3F3F3F3F227D
MySQL中的源数据已正确存储
[ { “关键”:“новый” } ]
字节 5b0a097b0a0909226b657922203a2022d0bdd0bed0b2d18bd0b9220a097d0a5d
如何正确配置类型转换?