utf 8 - JPA utf-8 characters not persisted -
i have simple web application use jpa.
i have entity called blogentry.
when submit new blogentry, when debug application see utf8 characters fine.
for example
em.persist(entity);
in line, if debug example:
entity.gettitle()
i can successfuly see utf-8 characters in ide. ( ğğ, or çç )
also, database has utf8 collation , can insert utf-8 characters fine sql using "insert into..."
however, jpa, characters persisted ????
why might be?
regards.
here persistence.xml:
<?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> <persistence-unit name="persistence"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <class>com.tugay.blog.core.model.blogentry</class> <properties> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver"/> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/blogdatabase"/> <property name="javax.persistence.jdbc.user" value="root"/> <property name="javax.persistence.jdbc.password" value="aabbccdd"/> </properties> </persistence-unit> </persistence>
use character encoding in property of persistence.xml file
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/blogdatabase?useunicode=yes&characterencoding=utf-8"/>
Comments
Post a Comment