views:

235

answers:

0

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 following configurations for Hibernate but that didn't solve the problem:
    - connection.useUnicode = true
    - connection.characterEncoding = UTF-8

    By the way, this all works fine if the MySQL columns are of type varchar. What am I missing? Any suggestions? Thanks