15 December 2005 in .Net, Tools | Comments enabled

I was reading about nHibernate generation over on David’s blog and added a comment which I thought could be posted here as well.

Possible nHibernate Logo

In the last few months a friend and I have been playing around with nHibernate a bit in various ways. I personally found that initially there was a bit of a high learning curve, mostly because I wasn’t aware of how like nHibernate Hibernate was. This meant that I initially disregarded all the Hibernate related content (first mistake :-) ). There isn’t much out there in the way of documentation for nHibernate unfortunately.

So initially we wrote a basic generator to take care of the generation for us. This all went well except when it came to generating the collections (one-to-many, many-to-many etc). That was until I found this site: http://www.xylax.net/hibernate/. After finding that my only problem was not correctly referencing the assembly and fully qualifying the classes used in the collections.

I’m about halfway through reading Hibernate In Action. So far it’s been quite good, it’s pretty easy to disregard any content that is too Java specific. I would strongly recommend it to anybody who is serious about getting their nHibernate/Hibernate data-layer working well. The book focuses on version 2.2 of Hibernate which is great as nHibernate is only functionally equal to this version (mostly ;) ).

Now I’m just looking forward to the next version of nHibernate which will hopefully include some .Net 2.0 features (Generic collections, nullable types). There are currently third party add-ins to enable this functionality but I’m not a huge fan of relying on third party components – it just makes upgrades more difficult.

- JD

P.S. The logo isn’t the official nHibernate logo, but one potential one.

Average Rating: 4.8 out of 5 based on 291 user reviews.

3 comments. Add your own comment.

David Givoni says 27 August 2006 @ 22:56

You wrote your own generator! Nice…

Did you end up using mygeneration or codesmith or did you stick with your own?

You’re absolutely right about the documentation. Most is better in the java hibernate docs and the differences are very small.

Btw, have you found a way to handle lazyloading and the nhibernate session in a decent way for web applications?


traskjd says 28 August 2006 @ 08:23

Thanks for the comment David :)

The generator was completely hand crafted. I was going to use XSLT to do the generation later but didn’t get around to that. I’ve since build a light weight generator that doesn’t spit out nHibernate code.

I haven’t yet used nHibernate behind a web application in a big way (as I was using it in a personal capacity and enjoy desktop application development more). The whole session management strikes me as a bit of a black art – it’s difficult to do well.

I still think nHibernate has a place but sadly I found the up-skilling required to be high, you need to know a lot about what is happening under the hood. I’m starting to look at LINQ for SQL and ADO.Entities now to see if they will be of more use to me in the future.

Thanks again for the comment David, perhaps we should exchange links?

– JD

David Givoni says 29 August 2006 @ 19:42

I found out after I posted the comment that your original post was from last december. I don´t know why I was notified now about the link…

Anyway, yes, I´d like to exchange links. I just put you up on my blog on the right side.

Have a good day,


Leave a Comment

Name (required)

E-mail (required - not published)


Your comment: