NHibernate Forge
The official new home for the NHibernate for .NET community

Get Started

Comments (6)
History (20)
75% of people found this useful

Get Started

This article give you a guide on how to setup NHibernate.Burrow framework for you project.
Configration setting in the Config file:

   1: <configSections>
   2:      <section name="NHibernate.Burrow" type="NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection, NHibernate.Burrow" />
   3:  </configSections>
   4:  <NHibernate.Burrow  >
   5:      <persistenceUnits>
   6:          <add name="PersistenceUnit1" nh-config-file="~/hibernate.cfg.xml"   />
   7:      </persistenceUnits>
   8:  </NHibernate.Burrow>

For web.config in ASP.NET applications, you also need to add a HttpModule Setting

   1: <httpModules>
   2:    <add name="NHibernate.Burrow.WebUtil.HttpModule"
   3:           type="NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil"/>
   4: </httpModules>

You'll need to maintain your hibernate configuration in the hibernate.cfg.xml (click here for a sample) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:

   1: <configSections>
   2:      <section name="NHibernate.Burrow" type="NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection, NHibernate.Burrow" />
   3:  </configSections>
   4:  <NHibernate.Burrow >
   5:     <persistenceUnits>
   6:          <add name="PersistenceUnitDB1" nh-config-file="db1hibernate.cfg.xml" />
   7:          <add name="PersistenceUnitDB2" nh-config-file="db2hibernate.cfg.xml" />
   8:     </persistenceUnits>
   9:  </NHibernate.Burrow>

That's pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line

   1: ISession sess = new BurrowFramework().GetSession(); //Gets the Burrow Managed NHibernate Session

Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.
( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don't need to explicitly get the managed session at all.)
If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service

   1:  new BurrowFramework.InitWorkSpace();//call this at the beginning (only when not in ASP.NET)
   2:  new BurrowFramework.CloseWorkSpace();//call this at the end (only when not in ASP.NET)

Recent Comments

By: Harshil Posted on 08-17-2011 9:34

why Burrow is not updated from past one year

By: LooDaFunk Posted on 01-13-2011 13:30

Thanks Shay!!!!! Fantastic it worked!!!!!!!!!!!!!!! thank you!!!!

By: jandark Posted on 12-30-2009 12:49

Could you update Burrow for NH 2.1.2.

When I setup Burrow I get following error:

Could not load file or assembly 'NHibernate, Version=, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

By: Karl Posted on 03-25-2009 16:06

I also needed to add preCondition="managedHandler" to the module in system.webServer for it to work.

By: Min.Han Posted on 03-16-2009 12:13

@Shay Jacoby,

One question, when moving to the IIS7 box did you put the httpModules in the <system.webServer> section?


View All
Powered by Community Server (Commercial Edition), by Telligent Systems