Logo

NHibernate

The object-relational mapper for .NET

Burrow

This page is converted from the old nhforge.org Wiki. First published by: kailuowang on 09-07-2008, Last revision by: Dario Quintana on 11-26-2008

Table of Contents

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)
© NHibernate Community 2024