NHibernate isn’t integrated to the compiler, so what?

I know, this title sound like: “hmm?” Let me explain it with more detail.

NHibernate is a framework that use natively Xml in order to configure a mapping between objects and tables, is in charged of join these different worlds.

But now, what is going wrong with this? Many people can say that Xml files are evil, because you should write a lot of lines, and when you build your project, the compiler doesn’t know if its ok or not, you have none errors. And this is true, you should run your project and see what happen in runtime, and to get an error in runtime is just annoying.

But now, do we have another alternative to this? Yes of course. Lets go to details. NHibernate has a “compiler” too, and you can guess what it is: BuildSessionFactory() method. You don’t have to launch the whole application to know if your mapping is working well. A way to know if everything is ok is create a test like this:

Then you just need to build the project, and run this simple and fool test, if your code pass though this, your mappings are ok.

We should remember one thing, you can map into Xml not just entities, you can map queries too (and another stuff that isn’t part of this matter). To map queries into Xml it calls: Named Queries, and in this post we talk about this matter. But the main point is, mapping the queries you will know if them are well formed when BuildSessionFactory() is raised, besides another beauties discussed in that post.

Another thing you should remember is you MUST use the Xsd to validate the mapping file. This is mandatory if you’re using NHibernate and you want to spend time programming instead of dealing with mapping errors (and here they come even with not-well-formed xmls). But this is topic to an How to or another post.

XUnit 1.0.2 and Resharper 4.1

XUnit doesn’t support yet to run tests on Resharper 4.1 so I decided to build a home-made release.

You can download this XUnit package tested with Resharper 4.1 and with TestDriven 2.14.2190. This is not an official release, you can get the official one in the Codeplex page,use at your risk:

Download

Hug a developer today

nhforge.org is ready !

Ok, this is what we were looking for a long time in the NHibernate community and I think we making it good. These past weekend, after a huge configuration process everybody can say: NHForge is up !

www.nhforge.org

Why nhforge? I think the “welcome” in the home site says enough.

There is something you should do if you are interested in NHibernate,you MUST suscribe to this feed: NHibernate blog.

NHibernate: Almost 2000 downloads on 3 days

In these 3 days NHibernate since the official release NHibernate 2.0 GA reached almost 2000 downloads. IMHO is a nice start for a .Net ORM tool.

What comes with this release

How much has change NHibernate since 1.2.1 till 2.0 GA ?

Patrick Smacchia sent me this link where NHibernate 1.2.1 GA and 2.0 GA are analyzed with NDepend.

I want to you appreciate the analysis made with this tool, to see how much of details it offers to build comparatives between both releases. What I consider the most important is the analysis of the changes made. You will see in the picture with the blue zones, all the refactored parts, and you can arrive to conclusions :)

NHibernate 2.0: Changes Overview

NHibernate Validator 1.0 CR1

I hope you enjoy this brandnew release of this amazing validator framework. Comes with more stability, more documentation, examples, and the most important point is the full compliance with NHibernate 2.0 GA.

Issues as usual must be reported in our issue-tracker.

Binaries, source and examples: download it here !

NHibernate 2.0 G.A. is release !

Enjoy it !

  

 Download NHibernate 2.0

Entering to microblogging

You can follow me here:

http://twitter.com/darioquintana

Thanks to Angel for share this video, but it’s on plain English, similar to Anglish :D

NHibernate: How much slow because the use of reflection?

NHibernate (as a lot of frameworks of IoC) has reflection optimizers to create objects, set and get field/properties. So you don’t have to be worried about that matter: NHibernate isn’t using a plain reflection approach.

This could be an very good argument at the time to “sell NHibernate” to: a customer, a Company or my boss. Have a look on the results of a demo proyect:

As you can see the use of the reflection optimized is faster than the use of reflection. Obviously direct access is the fastest way, but impossible to use in a ORM like NHibernate (as in many other frameworks).

Conclusions

  • Using reflection-optimizer, make the application faster than using of a plain reflection-approach.
  • Field access is faster than property access. This could be a good argument at time to choose field instead of property approach in our mappings files.
  • The obviously but we have to said it: direct access is always the fastest way.

You can download the demo application here.

Thanks to Fabio Maulo to make this example looks nicer. Gracias che !