See a solution for Hibernate+mysql Chinese problem on the Internet, as follows
System configuration: Win2k3 server,jsdk 1.5.0 rc,mysql 4.0.20a,hibernate 2.1.0, Elcipse 3.0.1
Problem Description: In the use of hibernate as a data persistence layer solution, we will encounter Chinese problems, when the specific situation of the Chinese characters inserted into the database display as???
Explore: After the test found that encoding related to the following two places, one is the database connection URL, one is programmed to get the configuration class instance of the way the statement.
Programme 1:
* The statement that gets the instance of the configuration class when programming is
* New Configuration (). addclass (Xx.class);
You must add the URL after the database is connected to the Hibernate.properties file. Characterencoding=gbk&useunicode=true
Programme 2:
* The statement that gets the instance of the configuration class when programming is
* New Configuration (). Configure ().
Set in the <session-factory/> block of a hibernate.cfg.xml file
<property name= "Connection.useunicode" >true</property>
<property name= "Connection.characterencoding" >UTF-8</property>
or write when programming:
Properties Extraproperties = new properties ();
Extraproperties.put ("Hibernate.connection.useUnicode", "true");
Extraproperties.put ("hibernate.connection.characterEncoding", "UTF-8");
Myconfiguration.addproperties (extraproperties);
But my son. In Hibernate3.1+mysql5, you must set both the parameters and the <property> properties of the URL, otherwise you cannot store Chinese properly