我需要获得NHibernate 2.1才能与oracle数据库对话。我需要使用Oracle 10g客户端。尝试建立会话工厂时出现以下错误:


无法转换类型的对象
'Oracle.DataAccess.Client.OracleConnection'
输入
'System.Data.Common.DbConnection'。


我不记得使用NHibernate 2.01遇到此错误。我正在尝试让服务器管理员安装11g客户端,但看起来这是一场失败的战斗。

以下是我的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组中问了同样的问题,并得到了可接受的答案。
将以下内容添加到休眠配置中:

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


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

07-24 22:21