Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with NHibernate 2.1 and Oracle 10g client

I need to get NHibernate 2.1 to talk to an oracle database. I am being required to use the Oracle 10g client. I get the following error when trying to build my session factory:

Unable to cast object of type 'Oracle.DataAccess.Client.OracleConnection' to type 'System.Data.Common.DbConnection'.

I don't recall getting this error with NHibernate 2.01. I am trying to get the server admins to install the 11g client, but it looks like that is a loosing battle.

Here are the important bits from my web.config:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <qualifyAssembly partialName="Oracle.DataAccess" fullName="Oracle.DataAccess, Version=10.2.0.100, Culture=Neutral, PublicKeyToken=89b483f429c47342"/>    
  </assemblyBinding>
</runtime>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
 <session-factory>
   <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
   <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
   <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
   <property name="connection.connection_string_name">Demo</property>
   <property name="show_sql">false</property>
   <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
  </session-factory>
</hibernate-configuration>

Full stack trace

at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare()
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at ConsoleApplication6.Program.Main(String[] args) in C:\\Dev\\Temp\\ConsoleApplication6\\Program.cs:line 26
like image 345
JohnRudolfLewis Avatar asked Dec 30 '22 18:12

JohnRudolfLewis


1 Answers

I asked this same question in the NHUsers group, and got an acceptable answer. Add the following to the hibernate configuration:

<property name="hbm2ddl.keywords">none</property>

See http://fabiomaulo.blogspot.com/2009/06/auto-quote-tablecolumn-names.html

like image 137
JohnRudolfLewis Avatar answered Jan 11 '23 20:01

JohnRudolfLewis