Configuration changes in NHibernate 2.0
I was upgrading an NH 1.x project to 2.0 recently, when I've found out there are actual config changes in NH 2.0, compared to the well known 1.x set of builds.
Long story in short, here it is:
In NH 1.x, we used to integrate NH into our projects by defining a new configuration section, like this:
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.1.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
This statement is being used for declaring our NH addiction. Then we add the actual section underneath:
<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.Oracle9Dialect"/>
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.OracleDataClientDriver"/>
<add key="hibernate.connection.connection_string" value="Data Source=//win2003:1521/dbname;Persist Security Info=False;User ID=username;Password=password"/>
<add key="hibernate.connection.isolation" value="ReadCommitted"/>
<add key="hibernate.default_schema" value="defaultschema"/>
</nhibernate>
<connectionStrings>
So, it turned out that in NH 2.0, we have a new type for the NH config section. Instead of using System.Configuration.NameValueSectionHandler, the NH dev team has switched that with a new type: NHibernate.Cfg.ConfigurationSectionHandler. Here's an example:
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
And the actual section:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="connection.connection_string">Data Source=//win2003:1521/dbname;Persist Security Info=False;User ID=username;Password=password</property>
<property name="default_schema">defaultschemanamegoeshere</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
Cheers,
Br.