learning
learning

Reputation: 11735

Set the property hibernate.dialect error message

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>

Upvotes: 0

Views: 1473

Answers (2)

learning
learning

Reputation: 11735

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

Thanks @Marjin for replying.

Upvotes: 0

Marijn
Marijn

Reputation: 10557

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.

Upvotes: 3

Related Questions