BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News NHibernate Lets Go of Iesi.Collections, Improves Support for SQL Server 2012

NHibernate Lets Go of Iesi.Collections, Improves Support for SQL Server 2012

This item in japanese

NHibernate 4.0 GA has been released. It comes with .NET 4.0 support, moving away from the Iesi.Collections library, and also supports some SQL Server 2012 features such as sequences and Query Paging.

There are three major changes in this release, one of which, moving to .NET 4.0, is a breaking change. As part of this, usage of the ISet from Iesi.Collection has been replaced by corresponding BCL generic type ISet<T> in the mapping classes. Support for persistent non-generic collections have been removed. ISet was not present in .NET BCL (Base Class Library) before 4.0, when NHibernate was initially created as a .NET port of Hibernate. This was one of the key reasons to have the Iesi.Collections library in the first place. Since .NET 4.0 introduced the ISet<T> interface, this library is now redundant, justifying this move. 

Note that NHibernate still has an internal dependency on the Iesi.collections library, but for most of the use-cases, developers can work with BCL implementations

In addition the 4.0 release adds support for ODP.NET - Oracle's Managed Data Provider for .NET, and some new Sql Server 2012 features in the SQL Server dialect:

  • Sequences - similar to existing support for Oracle and Postgres (before 2012, SQL Server had no sequences, and only an identity column for autogenerated pkeys)
  • The "iif" function
  • Query Paging - ensuring that the queries use OFFSET and FETCH when NH LINQ has Skip() and Take()

There are also several minor improvements including:

  • Math.Round() now supported in QueryOver Projections
  • Support for power() function in the SQLServer dialect
  • static fields in NHibernateUtil are no longer wrapped in NullableType or IType
  • Support for Postgresql Trigonometric functions
  • Some new overloads for Save/Update/SaveOrUpdate using Entity Names
  • Where() clause for many-to-many relation

Overall, there are more than a 100 bug fixes and minor improvements, some of which are potentially breaking changes. Have a look at the release notes, or the NH JIRA for the complete list.

What's next

Some work has already started for 4.1.0 - a quick look at the NH JIRA reveals several interesting new features that could come -

  • Support for Oracle 12c dialect. Oracle 12c supports identity columns, new paging keywords (FETCH FIRST and OFFSET) as well as some new types (VARCHAR2, NVARCHAR2, RAW)
  • PrePersist and PreUpdate attributes (similar to corresponding Hibernate annotations)
  • An NHibernateContext (alternative to DataContext) for WCF Data Services
  • Using property-refs with the <join> element

Possibility of NHibernate supporting of WCF Data Services is especially interesting, in the context of the confusion over future of WCF Data Services (although after a backlash, EF6 support was added to WCF Data Services after all).

NHibernate is a mature, open source object-relational mapper, ported over from it's Java cousin Hibernate. Once the undisputed ORM of choice, there have been concerns over future of NH in the wake of competition from the MS-supported, now open source, Entity Framework. (although there are several arguments in favor of NHibernate as well)

Rate this Article

Adoption
Style

BT