Problem retrieving Strings from varbinary columns using HIbernate and MySQL
Posted
by user303396
on Stack Overflow
See other posts from Stack Overflow
or by user303396
Published on 2010-03-28T00:24:28Z
Indexed on
2010/03/28
0:33 UTC
Read the original article
Hit count: 730
Hello,
Here's my scenario. I save a bunch of Strings containing asian characters in MySQL using Hibernate. These strings are written in varbinary columns. Everything works fine during the saving operation. The DB contains the correct values (sequence of bytes). If I query (again using Hibernate) for the Strings that I saved I get the correct results. But when Hibernate fills the entity to which the Strings belong with the values from the DB I get different values then the ones I used in the query that retrieved them. Instead of receiving the correct values I receive a bunch of FFFD replacement characters.
For example: if I store "??" in the DB and then I query for it, the resulting String will be \uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD.
- the DB connection has the following parameters set useUnicode=true&characterEncoding=UTF-8,
I've tried using the true UTF-8 configurations for Hibernate but that didn't solve the problem
What am I missing? Any suggestions? Thanks
© Stack Overflow or respective owner