Updated code for NHibernate articles Part 1 to Part 5

A while ago I wrote a series of articles about NHibernate and how mapping objects to classes is done using C#:

  1. NHibernate Part 1: Hello World with NHibernate
  2. NHibernate Part 2: CRUD with NHibernate
  3. NHibernate Part 3: Mapping techniques for aggregation – One To One mapping
  4. NHibernate Part 4: Mapping techniques for aggregation – One-To-Many mapping
  5. NHibernate Part 5: Mapping techniques for aggregation – Many-To-One and Many-To-Many mapping

At that time I used MySql and NHibernate version 1.0.0.0

Now I have updated the code to use a different tooling set and the 2.0.1.GA version of NHibernate.
The tooling set is:
Visual Studio 2008 of which there is a free version available here
SQL Server Express which you can download for free here

The updated code can be downloaded here.

NHibernate Part 5: Mapping techniques for aggregation – Many-To-One and Many-To-Many mapping

Updated code available for NHibernate 2.0.1.GA here.
The toolingset used is Visual Studio 2008 and Sql Server 2008

The final part in my experimentation series on NHibernate which discusses aggregation.

In this post I will discuss the following forms of aggregation:

  • many-to-one: an object is used by many other objects
  • many-to-many: an object is itself used by many other objects and vice versa

Continue reading

NHibernate Part 4: Mapping techniques for aggregation – One-To-Many mapping

Updated code available for NHibernate 2.0.1.GA here.
The toolingset used is Visual Studio 2008 and Sql Server 2008

Well, here it is: Part 4 in my experimentation series on NHibernate.

In this post I will continue with mapping strategies for aggregation and discuss the following form of aggregation:

  • one-to-many: an object uses a collection of objects of another type

But first I would like to eplain to you some more semantics on collections.

Continue reading

NHibernate Part 3: Mapping techniques for aggregation – One To One mapping

Updated code available for NHibernate 2.0.1.GA here.
The toolingset used is Visual Studio 2008 and Sql Server 2008

I finally got to writing my next post on NHibernate. I will be discussing Aggregation. I’m not an expert on NHibernate mapping but have done some experimentation in preparation for a project I’m working on and this post reflects my experiences during this experiments. If you should find any errors or know of other best practices, please let me know so that I can correct them.

But first, let me introduce to you the basic application that we will continue to use in the rest of this series.

Continue reading

NHibernate Part 2: CRUD with NHibernate

The Code

Updated code available for NHibernate 2.0.1.GA here.
The toolingset used is Visual Studio 2008 and Sql Server 2008

In the previous installment in this series of articles about NHibernate I explained a simple Hello World application which uses NHibernate to read messages from a database.

In this article we will learn how to perform basic CRUD operations. The CRUD acronym stants for the 4 operations which can be performed on data stored on a medium:

  1. Create
  2. Read
  3. Update
  4. Delete

We will continue to work with the database created in Part 1. All sample output also assumes you have excercised Part 1. Continue reading

NHibernate Part 1: Hello World with NHibernate

The Code

Updated code available for NHibernate 2.0.1.GA here.
The toolingset used is Visual Studio 2008 and Sql Server 2008

It’s been a few years now since I read for the first time about object relational mapping. It where a series of articles from Scott W. Ambler. At that time, this was a completely new appraoch but it got my attention firmly. It would however take some time and more reading to really get the importance of the concept.

The idea seeded to start experimenting with this concept and finally that time has come. After reading – searching the internet for some articles on NHibernate i didn’t realy find a “Hello World” type of application, with minimal overhead, that would get me in quickly. Most of the examples I found started with several objects and tables connected, implemented over several assemblies. Allthough they where good articles, what I wanted was a simple sample application, with one class mapped to one table showing me how to do a read operation with a minimum of overhead.

I decided to create this application myself.

Continue reading