Anyone having fun with NHibernateThis article from TheSeverSide gives a nice NHibernate overview, but I’m curious about how people are finding the config file management and the tool in general after a bit of real world use.

I’ve used a home grown version that did the same thing; it used a combination of .Net Reflection and CodeSmith.  I wonder if NHibernate is the way to progress in the future . . .

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

6 Responses to NHibernate

  1. This is to Sam,

    NHiberanteQueryAnalyzer blows up easily because it has poor exception support, the reason being that I started it as a throw away code to learn the internal of NHibernate and didn’t get the fact that this is a tool that people wants until it was too late, I spend the last few months refactoring the code and writing tests and generally making it much more stable. I’m currently in the stage where re-building the UI is all that I’ve left to do.
    This time I’m intending to make it far more proof for errors and much more stable.

    About your query:

    session.Query(“from Pet p where p.OwnerName
    in (‘bob’,’cindy’,’mike’)”)

  2. Most defaintly Yes.
    It’s a great piece of software, and I certainly intend to use it anywhere I can.

  3. Sam says:

    Thanks for the tip, will do!

    BTW, I think I figured out the “TOP” thing. SetMaxResults() or whatever doesn’t seem to do anything without SetFirstRecord() (or whatever). I’m not sure why. Doesn’t seem very intuitive.

    Still, can’t be helped.

    Oh, and another reason to love NHibernate: I’m already using log4net, so in my app.config I can just add a logger like so:

    And I get tons of really nice log information. I’m using it in production code in a WindowsService starting last Monday and it certainly seems to be tackling the job well, plus it’s just so beautifully clean code. I was using Paul Wilson’s mapper before, and overall it was adequate, but NHibernate is a lot cleaner, faster, and I don’t get the occassional transaction-out-of-scope exceptions the WORM would throw.

  4. NHibernate rocks! I’ve had a lot of fun working with it and using it with small projects. I’m still a bit hesitant to use it in production code but it feels pretty complete and solid at this point.

    As for documentation, you may want to check out the Hibernate Developer’s Notebook by O’Reilly. Although written in Java, it is very applicable to using NHibernate in .NET.

  5. Sam says:

    Yes. It’s perfecto. The app.config gets 4 lines, so that’s easy enough (this is not on a web-facing server so I haven’t bothered to setup any programmatic configuration yet), and each class gets it’s own embedded .hbm.xml. Once you mess with it for a bit the hbm’s are very easy to write and read. I actually use Mats Helander’s ObjectMapper to create the hbm’s tho’. It’s a little confusing, could be a lot simpler, and still have some bugs, but overall it’s definitely a big time-saver for a legacy database.

    The real beauty is the POCO-ness though. It’s by far the best O/R Mapper I’ve used. The only thing lacking is the docs. I still can’t figure out how to replicate a “Select Top 1 p From Pet as p Where p.OwnerName in (‘Bob’, ‘Cindy’, ‘Ted’)” statement with HQL or an IQuery. Everything else has been stupid-easy.

    It’s also a big pain that NHibernateQueryAnalyzer blows up so easily. I think it’s something to do with my custom build of NHibernate, but the only difference is that I wanted to use log4net 1.2.9 in my apps instead of 1.2.0.

  6. Darrell says:

    I hope so, especially seeing all the progress Hibernate is making and the widespread tool support.

Leave a Reply