NHibernate 2.1和Oracle 10g客户端出错

时间:2009-07-31 00:03:30

标签: oracle nhibernate oracle10g

我需要让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

1 个答案:

答案 0 :(得分:10)

我在NHUsers小组问了同样的问题,得到了一个可以接受的答案。 将以下内容添加到休眠配置:

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

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