Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nhibernate with Microsoft System.Data.OracleClient

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

Nhibernate Configuration (Is it correct for Microsoft Driver ?)

  <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.

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 ?

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

like image 426
Palani Avatar asked Mar 18 '09 09:03

Palani


People also ask

What is System data OracleClient?

OracleDataAdapter Class (System.Data.OracleClient) Represents a set of data commands and a connection to a database that are used to fill the DataSet and update the database. This class cannot be inherited.


2 Answers

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\

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

  <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
like image 95
Ian Nelson Avatar answered Oct 26 '22 23:10

Ian Nelson


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

like image 23
Yoann Avatar answered Oct 27 '22 00:10

Yoann