Problem:
I use Mysql 4.whatever with UTF8 set as default encoding.
Hibernate's <property name="connection.url">:
jdbc:mysql://localhost:3306/dictionary?useUnicode=true&characterEncoding=UTF-8&useOldUTF8Behavior=true
Have an object
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="lv.lu.mii.luweb2005.dictionary.domain.Text" discriminator-value="false" table="TEXT">
<id name="id" column="TEXT_ID">
<generator class="increment" />
</id>
<property name="urlOrigin" />
<property name="content" type="text"/>
<property name="added" type="timestamp" />
<property name="priv" type="boolean" />
</class>
</hibernate-mapping>
I save
with
Code:
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.save(newText);
tx.commit();
HibernateUtil.closeSession();
PROBLEM. If content is a string with unicode characters then the resulting string in mysql is chopped at the end by one for each unicode character.
So - i believe somewhere is a place which estimates the length of the string in unicode chars and tries to save it in real bytes to mySQL. As a unicode char == 2 bytes, we get lost.
Does anyone have any idea, what could be wrong?
I am completely new to Java, Hibernate and Mysql, so it could easily be some misconfiguration..