The people at Packt publishing asked me to review NHibernate 2: Beginner’s Guide by Aaron B. Cure.

Bookcover

This book is for anyone who uses NHibernate.

Who this book is written for

This book is for new and seasoned developers of .NET web or desktop applications who want a better way to access database data. It is a basic introduction to NHibernate, with enough information to get a solid foundation in using NHibernate. Some advanced concepts are presented where appropriate to enhance functionality or in situations where they are commonly used.

I have been using NHibernate for several (3 or 4) years now (man I sound old). And I like it a lot. In all these years, I have learned when to use it and when to leave it alone. These are things you will only learn by using it. This book won’t teach you this and it doesn’t pretend to want to do this. This book will also not teach you how to do Object Oriented (OO) programming. You should know OO before beginning with this and NHibernate in general. If you don’t do OO then an ORM (Object Relational Mapper) will sound weird and useless to you. If you don’t understand why VB.Net and C# programmers should do OO, you will have no need for this book.

It does show you how to solve the OO and relational incompatibility. It shows you how to do the mapping with XML and with Fluent NHibernate. It also shows you how to use a session and what a unit-of-work pattern is and when and why you should use that.

It shows you how to set the logger and how to use this to debug your code. It also shows you how to write queries and filters.

And at the end, it shows you how to use code generation to make writing code go faster with NHibernate.

And the best bit was that all code examples were in VB.Net and C#, but it got a bit boring to see “and here we have the same in VB.Net”. Clearly the author does not love VB.Net like some of us do. And he doesn’t need to, he just needs to hide it better.

So what do I think of this book? Although I have used NHibernate for a while now, you can always learn more. I learned a few little things and just for that, it was worth it. I learned that code generation is not for me (not in my situation anyway). I think this book is a good book for the beginning NHibernate user, both C# and VB.Net; you will learn a lot from it and you will have less frustrations than me to begin with. However, it is assumed that you know OO programming and that you know when to use it and when not. I can recommend it for seasoned NHibernate users as a quick read, you will perhaps not learn a lot from it – “the breadth of information presented may shed light on features of NHibernate that you’ve never had the opportunity to use before.” I learned what NHibernate Burrow was and what to use it for after having never looked into it before. And when and why to use MaxRequestLength.