设置属性 hibernate.dialect 错误消息

发布于 2024-10-09 13:53:09 字数 2057 浏览 2 评论 0原文

我在配置 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 如下:

<前><代码><节名称=“cachingConfiguration”类型=“Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching”/> <节名称=“log4net”类型=“log4net.Config.Log4NetConfigurationSectionHandler,log4net”/> <节名称=“hibernate-configuration”类型=“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>

I am having the following error when configuring mvc3 and Nhibernate. Can anyone guide me what I have missed please.

the dialect was not set. Set the property hibernate.dialect.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.

Source Error:

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


My web.config is as follows:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瑕疵 2024-10-16 13:53:09

从您的连接字符串来看,您似乎正在连接到 2k5 服务器。如果是这样,根据 NHibernate 文档,方言应设置为 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 是否适合您。

From your connection string, it appears that you are connecting to a 2k5 server. If so, according to the NHibernate docs, the dialect should be set to NHibernate.Dialect.MsSql2005Dialect.

This is the sample configuration from the docs:

<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>

You could try if setting dialect to NHibernate.Dialect.MsSql2005Dialect works for you.

纵山崖 2024-10-16 13:53:09

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

感谢@Marjin 的回复。

I have done a simple and stupid mistake. I have not included the right version of NHibernate.

Thanks @Marjin for replying.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文