Twproject, MySQL and UTF-8

Teamwork is MySQL partner.

This is a technical post about tand its databases.

Many Twproject customers use MySQL as database for their data; Twproject as web application supports UTF-8, which means that you can insert data in practically any language; but of course to save such data you need support along the “entire trip”, so your database must support UTF-8 data too. Now unfortunately MySQL default encoding is not UTF-8, but we found a way to work around that, which will be released with version 4.2: the Hibernate schema script generator will create UTF-8 encoding tables, as UTF-8 is supported also at table level (supported by MySQL 5),  so it will work in all cases.

This is done by simply extending the Hibernate MySQL5InnoDBDialect with

public String getTableTypeString() {
return ” ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci”;

as suggested here.

Remember to use MySQL 5 with referential integrity on and to end you JDBC url with “?useUnicode=true&characterEncoding=UTF-8”!

This is particularly important for our future Chinese customers, now that a Chinese translation is forthcoming.

Author: Twproject staff

Twproject is built by a small, solid and very efficient company. Its developers are ready to give support on the solution. Follow us for news, tips and updates.

One thought on “Twproject, MySQL and UTF-8”

  1. Really useful post, I was wondering how to tell NHibernate to create tables with UTF-8 charset by default!

    This was really helpful. I don’t know if that is the best way to do it. But it works!

Comments are closed.