I'm facing with UTF-8 encoding problem while persisting my model objects. In Turkish '?' is a letter. Also there're some other Turkish characters that is included in UTF-8 encoding. While I persist my model objects, all '?' characters are persisted as '?' to DB. I'm using MySQL 5.5 on Ubuntu Linux 64-bit OS. Also I've already set hibernate & c3p0 connection encoding property to UTF-8 too. When I debug, the data comes from client is true.
Here's my config and I'll be so happy if someone can help me.
Thanks in advance.
Spring & Hibernate Config
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="packagesToScan" value="com.tk.dms.model" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
<!-- c3p0 properties -->
<prop key="hibernate.c3p0.min_size">2</prop>
<prop key="hibernate.c3p0.max_size">50</prop>
<prop key="hibernate.c3p0.maxPoolSize">50</prop>
<prop key="hibernate.c3p0.minPoolSize">2</prop>
<prop key="hibernate.c3p0.initialPoolSize">2</prop>
<prop key="hibernate.c3p0.timeout">300</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
</props>
</property>
</bean>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…