Posts Tagged ‘.NET’

.NET and NHibernate

Friday, August 17th, 2007

Many Java programmers are familiar with ORM (Object Relational Mapping) tools and, in particular, Hibernate.  Hibernate allows a developer to map their relational database to their POJO (Plain Old Java Objects) and have Hibernate handle all the CRUD (Create, Read, Update and Delete) operations.

In the .NET world, ORM tools are much less common.  Many programmers follow a dataset focused approach to programming.  In earlier versions of ASP.NET, Microsoft offered data binding to many of its tools using datasets.  It just never occured to many programmers that there was a better approach.  So, when Hibernate was ported to .NET (as NHibernate), it was widely used by programmers that had used Hibernate, but it did not get the widespread acceptance that Hibernate received in the Java programming world.  With ASP.NET 2.0, Microsoft expanded its controls to allow binding to objects and collections of objects.  This created a greater demand for ORM tools.  Although still not as popular with .NET programmers as they are with Java programmers, ORM tools (and NHibernate in particular) are gaining market share.

In fact, Microsoft has been working towards building its own ORM capabilities (called LINQ) from directly within .NET applications without the need for a third party ORM tool.    However, its more focused around rewriting the syntax of queries and returning datasets that can, optionally contain objects, rather than removing the need to manually code CRUD operations.  I’ll write a separate blog about Microsoft’s LINQ product later on.

Whether Microsoft puts out a viable competitor to NHibernate has yet to be seen.  In the meantime, NHibernate offers some great functionality, is easy to use and saves programming time as programmers only need to define relationships in XML rather then write the CRUD code from scratch.

Interesting Links: