Im having problem when i try to save Patient with familyname = 'Lučić' in MYSQL database using hibernate + jpa.
When i do regular INSERT INTO, letter č and ć are displayed correctly in database and on my jsf form, so im sure that charset on my form is correct and in database.
Here is my hibernate configuration:
app_persistance.dialect=org.hibernate.dialect.MySQLDialect
app_persistance.show_sql=true
app_persistance.generateDdl=true
app_persistance.minPoolSize=1
app_persistance.maxPoolSize=10
app_persistance.connection.url=jdbc:mysql://localhost:3306/dentapp
app_persistance.connection.username=root
app_persistance.connection.password=root
app_persistance.connection.driver_class=com.mysql.jdbc.Driver
app_persistance.hibernate.connection.CharSet=utf8_croatian_ci
app_persistance.hibernate.connection.characterEncoding=UTF-8
app_persistance.hibernate.connection.useUnicode=true
app_persistance.hbm2ddl=update
I tryed to debug and check if value familyname in Patient object from jsf form has right values ( č, ć ) in serviceImpl:
@Override
@Transactional
public Patient save(Patient patient) {
return patientDAO.save(patient);
}
but everything seems to be fine in patient object so it has to be some problem with hibernate configuration. When hibernate+jpa is saving patient to db, it converts č,ć to ?? characters.
Can anyone point me to something, where i should look/read/check ?
Thanks !
解决方案
It seems that your connection is not using UTF8
Change
app_persistance.connection.url=jdbc:mysql://localhost:3306/dentapp
to
app_persistance.connection.url=jdbc:mysql://localhost:3306/dentapp?useUnicode=true&characterEncoding=utf-8