Error with NHibernate 2.1 and Oracle 10g client

梦想与她 提交于 2019-12-18 17:15:44

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/1210037/error-with-nhibernate-2-1-and-oracle-10g-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!