BT

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

by Roopesh Shenoy on Aug 26, 2014 |

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)

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Correction by Ricardo Peres

NHibernate 4.0 does not include a "NHibernateContext". Although an implementation exists, the feature is scheduled for later (see nhibernate.jira.com/browse/NH-2920).

Re: Correction by Roopesh Shenoy

@Ricardo - I agree - those bullets are for what might come next.

Maybe I should reword it better to be more clear?

Re: Correction by Roopesh Shenoy

I have added a bold sub-header to avoid all confusion. Hope that helps!

Edit by Roopesh Shenoy

Added a note on an internal dependency on Iesi.collections, along with a link to the discussion.

Re: Correction by Ricardo Peres

;-)

Entity Framework 5 and 6 vs NHibernate 3 – The State of Affairs by Dennis Doomen

Even after a year after my comparison between the two frameworks, NHibernate is still the best framework for building rich domain models. www.dennisdoomen.net/2013/03/entity-framework-5...

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

6 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT