Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Oracle and Character Encoding

Tags:

Im having an issue at the moment where my testing environment is not persisting the trademark character "™" in the database. When I enter in the form data, then submit it, I can see that on the server side, the request has the correctly encoded ™ character, but then when the call to hibernate's "saveOrUpdate()" method is called, the data in the table shows up as an upside down question mark.

Im using SqlDeveloper to inspect the table, and I can manually change the character to a ™ by pasting directly into the row then committing, and it works.

So I have made the assumption that hibernates methods of persistence are not working correctly.

Im at a loss here, really, I just dont know what to try, I have set the:

<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">utf-8</property>

properties in the config file, with no luck.

My columns in the tables are NVARCHAR2(400 CHAR) (although they were originally, just VARCHAR2 to start with, but I changed them during the debugging of this issue).

Any help here is greatly appreciated.

Mark

like image 498
Mark Avatar asked Aug 03 '09 23:08

Mark


1 Answers

Ok, so it turns out that what I needed to do was to set the defaultNChar connection property to true.

I did this via the context file for my app in Tomcat.

The article that enlightened me was here.

like image 189
Mark Avatar answered Oct 05 '22 14:10

Mark