Monthly Archives: September 2009

Using the NHibernate OR-mapper

I have decided to go ahead and set up a class that covers the basics and a few more advanced features of NHibernate. In order to take part in the class, please contact Dotway Stockholm at stockholm@dotway.se

As Domain Driven Design has won followers over legacy Data Driven Design people are focusing on mapping a business case directly into a set of objects that describe the problen space and true workflow, solving the problems the customer wants to solve and thus focus more on stringent, understandable and maintainable systems rather than focusing on what data the system will contain and how to store it cleverly, systems for abstracting away object persistence .have emerged. In the Java community Hibernate has been the big name over the years and in .NET NHibernate is establishing itself as the major player being the foundation for several solutions for automated persistence such as Castle ActiveRecord with the ActiveWriter modelling toolset.
 
This class is directed towards experienced .NET developers looking to migrate to NHibernate in production, either wrapping legacy databases or going greenfield domain-first. It covers a variety of tasks from the basic “getting started” via configuration through XML as well as FluentNHibernate to complex persistence solutions with some comparison to other persistence solutions such as Linq2SQL.
Topics covered in this class:

  • OR-mapper. Why?
  • Getting started
  • NHibernate vs … part I
  • Implementing a Sample Case
  • Session model
  • Lazy Loading
  • HQL
  • Schema versioning and deployment
  • Best practices
  • Worst practices
  • NHibernate vs … part II
  • Troubleshooting
  • Performance tuning

Starting with a very basic example of an ASP.NET MVC website I will expand and elaborate on a number of features in NHibernate, such as configuration, transactions, session scope, various key types, numbering schemes and lazy loading to show how to solve problems with NHibernate and how to retrofit NHbernate on top of existing schemas as well as how to create and version greenfield schemas. I will use a demo version of nhprof to demonstrate how the features, settings and tweaks as well as the chosen platform affect the SQL generated

I hope the class will instill a greater understanding of and confidence in NHibernate for use in your current project. If you wish there will be a fistful of code you will be able to use as a starting pont for your own exploration of NHibernate and its features.