nhibernate 3.0 通过 ODP.NET 连接 Oracle

发布于 2024-09-28 05:38:28 字数 1627 浏览 0 评论 0原文

有人可以告诉我下面的 nhibernate 配置有什么问题吗?使用最新的ODP.NET版本。

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
  <session-factory>
    <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
    <property name="connection.connection_string">DATA SOURCE=Oracle2;PERSIST SECURITY INFO=True;USER ID=***;PASSWORD=*****</property>
    <property name="show_sql">true</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
  </session-factory>
</hibernate-configuration>

我收到以下错误

Error 1 Test 'ODPNETNH.Tests.GenerateSchema_Fixture.Can_generate_schema' failed: NHibernate.MappingException : Could not compile the mapping document: ODPNETNH.Mappings.Vendor.hbm.xml
  ----> NHibernate.HibernateException : Could not instantiate dialect class NHibernate.Dialect.Oracle9Dialect
  ----> System.TypeLoadException : Could not load type NHibernate.Dialect.Oracle9Dialect. Possible cause: no assembly name specified.
at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
at NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping mappingDocument, String documentFileName)
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
at NHibernate.Cfg.Configuration.ProcessMappingsQueue()

Can someone tell me whats wrong with the nhibernate config below? Using the latest ODP.NET version.

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
  <session-factory>
    <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
    <property name="connection.connection_string">DATA SOURCE=Oracle2;PERSIST SECURITY INFO=True;USER ID=***;PASSWORD=*****</property>
    <property name="show_sql">true</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
  </session-factory>
</hibernate-configuration>

I get the following error

Error 1 Test 'ODPNETNH.Tests.GenerateSchema_Fixture.Can_generate_schema' failed: NHibernate.MappingException : Could not compile the mapping document: ODPNETNH.Mappings.Vendor.hbm.xml
  ----> NHibernate.HibernateException : Could not instantiate dialect class NHibernate.Dialect.Oracle9Dialect
  ----> System.TypeLoadException : Could not load type NHibernate.Dialect.Oracle9Dialect. Possible cause: no assembly name specified.
at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
at NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping mappingDocument, String documentFileName)
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
at NHibernate.Cfg.Configuration.ProcessMappingsQueue()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埋情葬爱 2024-10-05 05:38:28

我在使用 NHibernate 和 Oracle (ODP.NET) 时遇到了很多问题。
最后,唯一对我有用的是引用 Oracle.DataAccess.dll 版本。 2.111,为 DLL 指定Copy Local = true
在我的 Nhibernate 配置中,我使用了 Oracle10gDialect
最后但并非最不重要的一点是,我使用了这种新的连接字符串样式:

<property name="connection.connection_string">
      Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.1)(PORT=1522)))(CONNECT_DATA=(SERVICE_NAME=DIAP60FF)));User ID=myusername;Password=mypassword;</property>

I had quite a few problems working with NHibernate and Oracle (ODP.NET).
At the end the only thing which worked for me was to reference Oracle.DataAccess.dll ver. 2.111, specifying Copy Local = true for the DLL.
In my Nhibernate config I've used Oracle10gDialect.
Last but not least I've used this new connection-string style:

<property name="connection.connection_string">
      Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.1)(PORT=1522)))(CONNECT_DATA=(SERVICE_NAME=DIAP60FF)));User ID=myusername;Password=mypassword;</property>
烟雨凡馨 2024-10-05 05:38:28

我想我明白了。必须调用Configure(“hibernate.cfg.xml”);

I think I figured it out. Had to call Configure("hibernate.cfg.xml");

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文