【问题标题】:Set the property hibernate.dialect error message设置属性 hibernate.dialect 错误信息
【发布时间】:2011-01-06 18:38:51
【问题描述】:

配置 mvc3 和 Nhibernate 时出现以下错误。谁能指导我我错过了什么。

方言未设置。设置属性 hibernate.dialect。 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:NHibernate.HibernateException:未设置方言。设置属性 hibernate.dialect。

来源错误:

第 16 行:{ 第 17 行:NHibernate.Cfg.Configuration 配置 = new NHibernate.Cfg.Configuration(); 第 18 行:configuration.AddAssembly(System.Reflection.Assembly.GetExecutingAssembly()); 第 19 行: sessionFactory = configuration.BuildSessionFactory(); 第 20 行:}


我的web.config如下:

<configSections>
<section name="cachingConfiguration"type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching"/>
<section name="log4net"type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
<section name="hibernate-configuration"type="NHibernate.Cfg.ConfigurationSectionHandler,

NHibernate"/>

  <appSettings>
    <add key="BusinessObjectAssemblies" value="Keeper.API"></add>
    <add key="ConnectionString" value="Server=localhost\SQLSERVER2005;Database=KeeperDev;User=test;Pwd=test;"></add>
    <add key="ClientValidationEnabled" value="true"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
  </appSettings>



<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.connection_string">Server=localhost\SQLServer2005;Database=KeeperDev;User=test;Pwd=test;</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    </session-factory>
  </hibernate-configuration>

【问题讨论】:

  • 你试过NHibernate.Dialect.MsSql2000Dialect, NHibernate

标签: nhibernate asp.net-mvc-2 asp.net-mvc-3


【解决方案1】:

从您的连接字符串看来,您正在连接到 2k5 服务器。如果是,according to the NHibernate docs,方言应该设置为NHibernate.Dialect.MsSql2005Dialect

这是来自文档的示例配置:

<session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=(local);Initial Catalog=dbname;User Id=user;Password=********</property>
</session-factory>

如果将方言设置为 NHibernate.Dialect.MsSql2005Dialect 适合您,您可以尝试。

【讨论】:

    【解决方案2】:

    我犯了一个简单而愚蠢的错误。我没有包含正确版本的 NHibernate。

    感谢@Marjin 的回复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-18
      • 1970-01-01
      • 1970-01-01
      • 2013-03-17
      • 2017-07-17
      • 2011-10-07
      相关资源
      最近更新 更多