5

I have a problem with in JPA - EclipseLink characterEncoding problem. My project's persistent.xml is ;

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="jpa-1" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>com.usta.jpa1.KITAPLAR</class>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/dBase"/>
      <property name="javax.persistence.jdbc.password" value="app"/>
      <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
      <property name="javax.persistence.jdbc.user" value="app"/>
      <property name="eclipselink.ddl-generation" value="create-tables"/>
    </properties>
  </persistence-unit>
</persistence>

But, i run the my application, the object saved into my database, then my turkish characters arent be displayed correctly. i wanna change the encoding character set to UTF-8. I find the ;

<property name="hibernate.connection.useUnicode" value="true" />
<property name="hibernate.connection.characterEncoding" value="UTF-8" />

then not find the eclipseLink equivalence

Rahman Usta
  • 716
  • 3
  • 14
  • 28

1 Answers1

3

It does indeed seem like EclipseLink has no implementation specific config param for the encoding:

http://www.eclipse.org/eclipselink/api/2.2/org/eclipse/persistence/config/PersistenceUnitProperties.html

However, make sure that your project is compiled in UTF-8 format. check that Eclipse is correctlly configured : Window->Preferences->General->Workspace text file encoding is UTF-8. Also if it's the case, configure your Maven project to compile in UTF-8 as well:

http://maven.apache.org/general.html

Shivan Dragon
  • 15,004
  • 9
  • 62
  • 103
  • thanks, my ide is Netbeans, my netbeans project's encoding type was UTF-8 but Source/Binary Format was 1.5, my jdk is 1.6 , i changed it to 1.6 then it correctly run – Rahman Usta Oct 26 '11 at 12:47
  • 1
    I too had same issue. I solved it by appending to my connection url as jdbc:mysql://host:port/dbName?useUnicode=true&characterEncoding=UTF-8 – Xavier DSouza Mar 18 '14 at 10:52