NHibernate 3.2, What’s New?

The newest release is as BETA 1 when writing this blog an it contains some new and nice features. One of my favorite is that as a programmer we no longer need to configure a proxy. It was always a little confusing knowing which one to choose, I.e. looking in the Required_For_LazyLoading directory and deciding which proxy provider to use, be it Castle, LinFu or Spring. There was never really any good documentation on which one is best, so it is good that it is gone and that a default is provided.

The second cool thing is that we can say good-bye to the mapping files. This has been a feature available within Fluent NHibernate for some time, but has now been implemented into the NHibernate.Mapping.ByCode namespace. An example of mapping by code is shown below.

public class CustOrderMap : ClassMapping<CustOrder>
         public CustOrderMap()
             Id<Guid>(x => x.Id, map =>
             Property<DateTime?>(x => x.ODATE,
                              map => map.Column("ODATE"));
             Property<decimal?>(x => x.TotalAmount,
                              map => map.Column("TotalAmount"));           

You will need to use the ModelMapping and HbmMapping methods to bind the mappings to the Configuration before the Session Factory is instantiated.

There is also a new SQL Azure dialect.

There are numerous other improvement and bug fixes, however the above are the most significant, at least IMO.