Some of you may have noticed that several pages on this blog have been generating 404 errors for the past week or so. This was due, in part, to my recent migration to a Windows Server 2008 (IIS7) machine. Most of the blogs service interruption could have been avoided had I properly "test drove" the website after the migration. But in my haste I simply transferred the files to the remote server, hit the home page, and called it a night. Little did I know that most of the blogs content was unreachable.
In the past I have talked about the The Wonders Of InternalsVisibleTo and how such a simple attribute allows for internal components to be shared between different assemblies, opening the door to greater code separation and dependency control. In that previous article I illustrated how you can use the tool that ships with Visual Studio to get the public key signature from one of your existing dlls.
The NHibernate documentation is often very handy when working on NHibernate based project. I keep PDF copies of the documentation to NHibernate 1.0 and 1.2 on my hard drive as I never know when I will need to reference them. Unfortunately the NHibernate team seems to have dropped the ball in regards to version 2.0. Not only does the NHibernate website lack any documentation on version 2.0, the website acts as if version 2.0 hasn’t even been released yet. Unlike previous updates to the framework, version 2.0 represents a complete refactoring of the code base with many namespaces and objects either removed or renamed. Despite the lack of official documentation there are still several resources to help you migrate your existing NHibernate 1.2 application to NHibernate 2.0.
List of breaking changes
The NHibernate forum has a thread discussing the breaking changes between version 1.2 and an alpha pre-release of 2.0. For the complete list check out the forum, however here are the ones you will be most likely to face.
Problem: The NHibernate.Expression namespace no longer exists.
Overview: Most notable of the items formerly kept in this namespace was the Expression object used when creating ICriteria. Fortunately the object still existing in the NHibernate.Criterion namespace.
Solution: Replace all “using” statements to reflect the namespace change.
//using NHibernate.Expression; //this line is no longer needed in NH 2.0 using NHibernate.Criterion; //replace it with this line.
Problem: The nhibernate configuration section (most likely in your web.config or app.config) is no longer used.
Overview: NHibernate 2.0 no longer looks at the configuration section named nhibernate, instead it looks for a configuration section called hibernate-configuration (notice the lack of an “n” in hibernate). Moreover the configuration section wasn’t simply renamed, it bears and entirely different schema.
Solution: In short the entire configuration section is going to have to be reworked slightly.
For starters your configuration section declaration will have to change its name and type:
<configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" requirePermission="false"/> </configSections>
You read that correct, source control is for toddlers. Not for toddlers to use, but rather to protect us from them. Surely the sole purpose of products such as Subversion, TFS, et. al. was to protect society from these pint sized keyboard loving terrors.