Monday, August 25

NHibernate

I've start to work on a new project.
One of the base building blocks of that project is something we call "bank".
Bank can be anything from simple list of items (which maps to simple table in a database) to a complex network of objects like tree for example (which maps to several tables with relation in a database).

I've start to write some sample code to see how I can solve this problem. I've worked for a week just to produce a solution to loading a bank from a database tables. I've not yet got to saving the bank back to the database.

Then, after talking to a friend about this problem, I've got to learn about NHibernate.
After few hours of reading the getting reference document and searching the web I've got a solution for both loading and saving virtually any form of bank to and from a database tables.

I have to say I am amaze from the easy of use and the abilities NHibernate has. All the plumbing of tracking the objects state (loaded, modified, delete) are now in the hand of NHibernate, yet I can "plug" into the process using various plug-in points left by the developers of NHibernate to observe or participate in the process of loading and saving the objects.

Next time I'll write about "dynamic bank" - how to let the user define bank without the need to create database table.