The more I work with it the more stupid I feel around what I have been doing before; why have I written so much SQL? It feel just … unnecessary. Who said stupid? Not me…
Jimmy Nilsson said something like; “I just want the database and storage problems to be a consequence of my domain model. I don’t want to think about it”. And that is one of the goals with DDD and the solution is, for example, NHibernate.
I have been doing some labs with NHibernate the last couple. And as often with me – I think I am in love. NHibernate really rocks. The mapping files are quite hard to chew off at first and I suspect that there are many tricks and traps for me to find. But still – so beautiful.
Of course the Net has helped me a lot on my quest. Here are some articles that I’ve used:
- The NHibernate API Reference
- A great first-time tutorial that helped me in the early stages
- Here is a great couple of articles describing the unit of work pattern implemented with NHibernate (part 1, 2, 3)
- More advanced mapping scenarios
- Description on how to map many-to-many entities, without having to specify a connection entity that matches the connection table.
A bit on the sad side (or NOT) is that we were trying to create a Unit Of Work implementation for NHibernate. Not only has this been done before, but also apparently NHibernate hooks into the System.TransactionScope implementation of the .NET framework. Thanks a lot to the gurus of level 3 – Magnus and Calle who show me that. All my code – down the drain… :)
OK – this has been a great learning experience. If you want the code – drop me a line and you’ll have it in a jiffy.
If you liked this post ... here's more for you:
Published byon Last updated