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

Bookmarks

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

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.

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

Community comments

  • Correction

    by Ricardo Peres,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    @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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

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

  • Edit

    by Roopesh Shenoy,

    Your message is awaiting moderation. Thank you for participating in the discussion.

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

  • Re: Correction

    by Ricardo Peres,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    ;-)

  • Entity Framework 5 and 6 vs NHibernate 3 – The State of Affairs

    by Dennis Doomen,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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...

  • NHibernate is better than Entity Framework 5 or 6

    by Janice Noel,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    NHibernate is much more feature rich and is lot better to use than EntityFrame work 5 or 6. Our development team uses NHibernate mostly at www.itransition.com

  • Any alternative?

    by Krishna Lomeli,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Ok, nice vision of the shifting to NHibernate. But is there an alternative for the .Net developers? We at pnn soft www.pnnsoft.com/ use mostly WCF, WPF, SOA, Rest, ODBC, ADO.Net, LINQ, RPC, Web Services, RESTfull, JSON, AJAX, ClickOnce, Silverlight. Is NHibernate better than all these…
    Any suggestions?

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

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

BT