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>

3
  • 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. Commented Sep 27, 2011 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. Commented Sep 28, 2011 at 10:02
  • Potentially related question: stackoverflow.com/questions/1192281/… Commented Sep 28, 2011 at 10:06

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.