oracle 使用 Microsoft System.Data.OracleClient 进行休眠

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/657507/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:56:39  来源:igfitidea点击:

Nhibernate with Microsoft System.Data.OracleClient

oraclenhibernate

提问by Palani

I am trying to use Nhibernate with Oracle using Microsoft's System.Data.OracleClient

我正在尝试使用 Microsoft 的 System.Data.OracleClient 将 Nhibernate 与 Oracle 一起使用

Nhibernate Configuration (Is it correct for Microsoft Driver ?)

Nhibernate 配置(对于 Microsoft 驱动程序是否正确?)

  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="show_sql">true</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="cache.use_second_level_cache">true</property>
      <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
      <property name="cache.use_query_cache">true</property>
      <property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
      <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
      <property name="connection.connection_string">Data Source=localhost;User Id=jbadmin;Password=justbooks12;Integrated Security=no;</property>
    </session-factory>
  </hibernate-configuration>

Its throwing Exception,

它的抛出异常,

The IDbCommand and IDbConnection implementation in the assembly Oracle.DataAccess could not be found. Ensure that the assembly Oracle.DataAccess is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly. 

I tried copying System.Data.OracleClient.dll to output bin directory. It didn't help. I also tried copying Oracle Client dlls to output bin directory. It also didn't help.

我尝试将 System.Data.OracleClient.dll 复制到输出 bin 目录。它没有帮助。我还尝试将 Oracle Client dll 复制到输出 bin 目录。它也没有帮助。

Exception says 'Oracle.DataAccess' assembly not found. But there is no such assembly inside Microsoft's System.Data.OracleClient. Is it searching for Oracle's ODP Drivers ?

异常表示未找到“Oracle.DataAccess”程序集。但是在微软的 System.Data.OracleClient 中没有这样的程序集。是否在搜索 Oracle 的 ODP 驱动程序?

Edit:If above Configuration is wrong , help me by posting Configuration for System.Data.OracleClient

编辑:如果上述配置是错误的,请通过发布 System.Data.OracleClient 的配置来帮助我

回答by Ian Nelson

This line in your configuration:

您的配置中的这一行:

  <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>

is instructing NHibernate to use the ODP.NET drivers found in Oracle.DataAccess.dll . This allows NHibernate to make use of ODP.NET features such as Connection Pool and tracing. Depending on the version of Oracle client software installed, you should find a copy of this assembly somewhere like C:\Oracle\product\10.1.0\Client_1\BIN\

指示 NHibernate 使用在 Oracle.DataAccess.dll 中找到的 ODP.NET 驱动程序。这允许 NHibernate 使用 ODP.NET 功能,例如连接池和跟踪。根据安装的 Oracle 客户端软件的版本,您应该在 C:\Oracle\product\10.1.0\Client_1\BIN\ 等位置找到该程序集的副本

If you would prefer to use Microsoft's System.Data.OracleClient driver instead, change this line to:

如果您更喜欢使用 Microsoft 的 System.Data.OracleClient 驱动程序,请将此行更改为:

  <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>

回答by Yoann

Using the microsoft oracle driver will slow down your performance by a lot.

使用 microsoft oracle 驱动程序会大大降低您的性能。