All posts tagged 'nhibernate'

.NET Musings

Wandering thoughts of a developer, architect, speaker, and trainer

NAVIGATION - SEARCH

NHibernate 1.2 vs. 2.0.x vs. 2.1.0 Configuration Settings

Technorati Tags:

There are a great deal of really cool changes between NHibernate 1.2 and 2.0.1 and 2.1.0, but the one change that I get the most questions about is configuration. Between each of these versions the configuration has changed.

Web.Config/App.Config Settings for Version 1.2:
 
<configuration>
  <configSections>
    <section name="nhibernate"
       type="System.Configuration.NameValueSectionHandler, System,
       Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <nhibernate>
    <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
    <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect"/>
    <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
    <add key="hibernate.connection.connection_string" value="{blah blah}"/>
    <add key="hibernate.connection.isolation" value="ReadCommitted"/>
  </nhibernate>
</configuration>
Web.Config/App.Config settings for Version 2.0.x
<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, NHibernate</property>
      <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Server={blah blah}</property>
      <property name="connection.isolation">ReadCommitted</property>
    </session-factory>
  </hibernate-configuration>
</configuration>
Web.Config/App.Config settings for Version 2.1.0
<configuration>
  <configSections>
    <section
      name="hibernate-configuration"
      type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory name="Sample.DAL.Tests">
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Data Source=localhost\dev08;Initial Catalog=SteveB;Integrated Security=True;</property>
      <property name="show_sql">true</property>
      <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
      <property name="connection.isolation">ReadCommitted</property>
      <property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
      <mapping assembly='SteveB'/>
    </session-factory>
  </hibernate-configuration>
</configuration>


Hopefully this will help out those transitioning from 1.2 to 2.0 to 2.1.0 (or, looking at a one version’s sample and trying to get it to work in 2.0)

Happy coding!

Managed Windows Shared Hosting by OrcsWeb