Alexandre H. Tremblay Alexandre H. Tremblay - 5 months ago 30
Java Question

Eclipselink auto creates utf8_unicode_ci

When I start my application, eclipselink is set to auto drop and create the table in the database. I have set it up to create an InnoDB engine using the table creation suffix. However, I would like the text encoding to be utf8_unicode_ci. How can I set up my xml file to achieve that. Right now, it defaults to utf8_general_ci.

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi=">
<persistence-unit name="Data">


<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/data" />
<property name="javax.persistence.jdbc.user" value="username" />
<property name="javax.persistence.jdbc.password" value="password" />

<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.ddl-generation.table-creation-suffix" value="engine=InnoDB " />


It's been a while since you have asked this question, anyway I am posting this answer by chance if any one wants to know.

Change your "javax.persistence.jdbc.url" properties value from




This will enable unicode support for your database.
Hope you had figured it by now ;)