0

I am using the config below for NHibernate to connect to Oracle. In one of the classes, I am storing a unicode string such as 日本語 (日本). The data field for the column is NVARCHAR2() however, when retrieving the data, the value is corrupt showing ??? (??). Somewhere along the line I'm losing my encoding, but am a loss as to where. Any ideas?

  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
  <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
  <property name="connection.connection_string_name">Oracle</property>
  <property name="show_sql">true</property>
  <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
  <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
  <property name="cache.use_second_level_cache">true</property>
  <property name="adonet.batch_size">30</property>
  <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
  <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
</session-factory>

Ray Booysen
  • 28,894
  • 13
  • 84
  • 111
  • 1
    How do you identify that the information is lost when you retrieve it? The most solid way to check it would be to see if the byte array would match in the selected encoding (I assume UTF-8), to just rule out a font problem. – jishi Sep 27 '11 at 11:39
  • Selecting both with PL/SQL and Linqpad show the corrupt strings. I haven't done a byte by byte comparison yet, but I did assume (perhaps incorrectly) that one of these tools would work appropriately. – Ray Booysen Sep 28 '11 at 10:02
  • Potentially related question: http://stackoverflow.com/questions/1192281/how-to-save-unicode-data-to-oracle/1192290#1192290 – Ray Booysen Sep 28 '11 at 10:06

2 Answers2

1

NHibernate dose not use NVarChar2. If you want NHibernate to use NVarchar2 than you have to write your own database dialect.

0

No need to write a custom dialect, a user type is enough. See my answer to this question: https://stackoverflow.com/a/61792204/5168579

Robert J
  • 704
  • 10
  • 8