NHibernate 2.1和Oracle 10g客户端错误 [英] Error with NHibernate 2.1 and Oracle 10g client
问题描述
我需要获得NHibernate 2.1才能与oracle数据库对话.我需要使用Oracle 10g客户端.尝试构建会话工厂时出现以下错误:
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:
无法转换类型的对象 'Oracle.DataAccess.Client.OracleConnection' 输入 "System.Data.Common.DbConnection".
Unable to cast object of type 'Oracle.DataAccess.Client.OracleConnection' to type 'System.Data.Common.DbConnection'.
我不记得NHibernate 2.01出现此错误.我正在尝试让服务器管理员安装11g客户端,但这看起来是一场失败的战斗.
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.
以下是我的web.config中的重要内容:
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>
完整堆栈跟踪
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
推荐答案
我在NHUsers组中问了同样的问题,并得到了可接受的答案. 将以下内容添加到休眠配置中:
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>
请参见 http://fabiomaulo.blogspot.com/2009 /06/auto-quote-tablecolumn-names.html
这篇关于NHibernate 2.1和Oracle 10g客户端错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!