NHibernate 和 Oracle 的 Unicode 字符串
我使用下面的配置让 NHibernate 连接到 Oracle。在其中一个类中,我存储了一个 unicode 字符串,例如日本语 (Japan)。该列的数据字段是 NVARCHAR2(),但是,在检索数据时,该值已损坏,显示 ??? (?)。沿着这条线的某个地方,我丢失了我的编码,但不知道在哪里。有什么想法吗?
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NHibernate 不使用 NVarChar2。
如果您希望 NHibernate 使用 NVarchar2,那么您必须编写自己的数据库方言。
NHibernate dose not use NVarChar2.
If you want NHibernate to use NVarchar2 than you have to write your own database dialect.
无需编写自定义方言,用户类型就足够了。看我对这个问题的回答:
https://stackoverflow.com/a/61792204/5168579
No need to write a custom dialect, a user type is enough. See my answer to this question:
https://stackoverflow.com/a/61792204/5168579