• Coding
  • Who uses NHibernate? (Kind of a Poll)

This is explicitly for .Net developers. I am curious who actively uses NHibernate to develop, please raise your hands :)
+ ActiveRecord exclusively.
For now I'm happy with the Entity Framework but I've heard good things about NHibernate. I'm currently (right now) reading a tutorial about how to set up NHibernate and build a small CRUD application using it. But I've noticed that you have to do a lot of configuration in order to get started with it, as opposed to EF which does almost everything for you. Is that true, or is it just the case of this particular tutorial?

Also, I'd like to know whether NHibernate has any issues with int identity attributes like EF has. EF cannot auto increment the primary key if your DB engine is SQL CE.

Any other thoughts?
Entity Framework is and apparently will stay the new kid on the block. In other words it is an immature OR mapping engine. NHibernate on the other hand is a port from Hibernate for Java, meaning it has matured enough and has undergone a lot of testing and usage. I tried using Entity Framework (I actually did use it in a small application) but noticed a lot of shortcomings.

Concerning your questions, it is easy to setup NHibernate, the first time will be a bit hard trying to get around it but after that it is simple. It is most of the time (if not always) a matter of compromise between control and ease of setting up, NHibernate gives more control than EF where (to me) EF looks more like the RAD approach MS takes when giving the community tools (at some point I stopped taking seriously their wizards and controls that look easy to use). You also have to think Object Oriented, so it is better to think classes and their associations than to think tables and relations. So starting from the Object model and designing the database accordingly is better when possible.

How are you exactly using EF, are you generating the classes from an existing database schema? I can tell you how I am using NHibernate and mabye that would help:

I design my classes and write them in C# using any OO feature I see fit (Inheritence, Polymorphism, etc...) I then design the tables that correspond to the classes (for more information about the mapping between classes and tables and how many classes per table or tables per class, you will need a good book, I recommend NHibernate In Action).The final step is to map your Object Model (classes) to your DB schema (tables) and for that you have options. The defacto methods are either using xml mapping file or using .Net attributes. On the other hand I find that using Fluent NHibernate much more helpful and practical fluentnhibernate.org

I have not used SQL CE before with NHibernate, but in SQL Server identity fields are common and handled by NHibernate.
The fluent interface has found it's way into several other libraries. It does wonders with NHibernate.
Honestly, I find that many of the .NET's new technologies are still immature and could use some improvement. And I think that's why there are many external projects - if I may say - that are currently being developed to replace some of Microsoft's, such as ORM's, ViewEngines and the likes. But still, that doesn't mean that Microsoft isn't doing a good job on its new technologies, I believe it's just a matter of time until they get it "right".

On a side note, I've got myself a copy of the book recommended by MSD (NHibernate In Action), I'll try to read it after my partial exams. Will also take a look at the fluent interface.

By the way, in the tutorial I was reading, I read something about HQL and HCQ. Are these an alternative to using LINQ or something?
Kassem wroteBy the way, in the tutorial I was reading, I read something about HQL and HCQ. Are these an alternative to using LINQ or something?
HQL is the hibernate query language, in the current (2.x) version of (n)hibernate, apart from the standard ways of querying the repository through functions, it allows you to use queries (as strings) to communicate with the repository.

As of NHibernate 3.0, which is currently in Alpha, there will be support for direct LINQ queries, and this is something i'm looking forward to.
HQL (Hibernate Query Language) is a way to query for persistent objects using a syntax comparable to some degree to SQL. HQL is written as strings and processed by an engine in NHibernate. LINQ on the other hand is integrated within the language itself and is supported by intellisense. There is a project to try to get the power of both together http://www.hookedonlinq.com/LINQToNHibernate.ashx. So instead of writing strings to query for objects linq expressions are used which are translated internally into HQL (if I am not mistaken).

Concerning HCQ, I still cannot find out what it is, anyone?