Job Search
  |  Blog
  |  Contact
  |  Site Map
  |  Home
  |  

NHibernate configuration issues and ASP.NET problems

Blog Date: Saturday, September 6, 2008 - Discuss below!

Recent Blogs

<< Back

C#: How to Display object hierarchy in TreeView using reflection 7/7/2008

Email addresses for sending SMS text messages 7/13/2008

Fundamentals of WCF Security 8/13/2008

 More Blogs...
 

IT Jobs Hiring


Business Intelligence Programmer Analyst North Chicago, IL

.NET Developer - PROVEN, Inc. San Diego, CA

More jobs...
 

Tutorial:

http://www.hibernate.org/362.html

 "Could not find the dialect in the configuration"

First of all,

You can put a Try...Catch around the session creation and look at the inner exception.

 

Here is an example of how an App.config looked for NHibernate 1.2:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <nhibernate>
    <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
    <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
    <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
    <add key="hibernate.connection.connection_string" value="Data Source=127.0.0.1\SQLEXPRESS;Initial Catalog=DbWorkshop;Integrated Security=True" />
  </nhibernate>
</configuration>

And here is the equivalent for version 2.0:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <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">Data Source=127.0.0.1\SQLEXPRESS;Initial Catalog=DbWorkshop;Integrated Security=True</property>
    </session-factory>
  </hibernate-configuration>
</configuration>

The main changes are:

  • We aren't using an nhibernate configuration section, it's hibernate-configuration now (yay for more typing! :P).
  • We now have a session-factory child node for adding the configuration properties.
  • We aren't adding properties using the <add key="..." value="..." /> syntax. Instead we are using <property name="...">(property value)</property>.
  • The property names aren't prefixed by "hibernate" anymore, so "hibernate.connection.provider" becomes "connection.provider".


Saturday, September 06, 2008 1:02:15 PM