NHibernate 2.0 Offers Many New Features
NHibernate 2.0 Alpha has been released this week. The current 2.0 release is the first step to the feature set of Hibernate 3.2.6, many classes have been completely rewritten and lots of features have been added.
InfoQ has had a chance to talk to Karl Chu, the project lead, as well as Ayende and Fabio Maulo about the details on the 2.0 release. When asked about the most important changes in 2.0 Karl responds:
There a lot of changes from 1.2 to 2.0. If I were only allowed to pick one or two, I think the new inheritance mapping strategies (i.e.
and ) and the new events infrastructure have the most impact. They add tremendous flexibility.
Ayende has posted an extensive list of all the changes and new features on his blog. He agrees with Karl on the importance of the new Events, Actions and Listeners feature and adds the "major improvements to the Criteria API", especially Multi Criteria, which allows to "perform multiple queries against the DB in a single DB round trip and enabling interesting scenarios with batching queries".
The Events, Actions and Listeners feature offers means "to interfere with the way NHibernate performs its actions", says Ayende. "This is useful in many scenarios where you want better control on what NHibernate is doing". According to Fabio Maulo "what you can do with writing or overriding NH default event is limited only by your imagination". NHibernate shows many ways of making use of the event feature, e.g. NHibernate.Validator uses event/listeners, the future NHibernate.Search and NHibernate.Shards uses events and NHibernate AddIns provide examples on how to use events to merge NHibernate with the EnterpriseLibrary Validation-Application-Block.
Concerning the "Alpha" status Ayende explains:
We call this alpha, but many of us are using this in production, so we are really certain in its stability. The reason that this is an alpha is that we have made a lot of changes in the last nine months (since the last release), and we want to get more real world experience before we ship this. Recent estimates are of about 100,000 lines of code has changed since the last release.
Although many features have been added, "most of the work happened in the core", says Ayende, "porting the Hibernate 3.2 features and changing large parts of NHibernate to match the existing Hibernate 3.2 code base". Fabio points out that "NHibernate 2.0.0 is only the first step to Hibernate 3.2.6" and that release 2.1.0 will finally close the gap.
On support for LINQ queries Karl Chu says: "I personally believe the success of NHibernate.Linq will play an important role in the continual success of NHibernate". Ayende elaborates on the Linq for NHibernate (NHibernate.Linq) sub-project:
Linq for NHibernate is an ongoing effort, right now we have a baseline functionality, working against NHibernate 2.0 Alpha 1.
We are working on getting the advanced scenarios working. Once we got that, we will merge Linq for NHibernate into the NHibernate project (probably as a contrib project for now) and release it with NHibernate.
Note that NHibernate will remain fully compatible with .NET 2.0, Linq for NHibernate will be an AddOn.
The roadmap for NHibernate 2.x "is to have all the features in Hibernate 3.2; we are not very far from that", claims Karl Chu.
Juli Lerman writes about NHibernate 2.0 Alpha and its relationship and positioning to Entity Framework pointing out that "EF still has a long way to go, so in the meantime nHibernate continues to get stronger and stronger".
Ben Linders May 28, 2015