NH Forge
The NHibernate community site.

Get Started


Page Details

First published by:
on 09-07-2008
Last revision by:
on 09-07-2008
2 people found this article useful.
Comments (0)
History (13)
100% of people found this useful

Get Started

Filed under: [Edit Tags]

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" />
   3:  </configSections>
   4:  <NHibernate.Burrow  >
   5:   <persistantUnits>
   6:    <add name="PersistenceUnit1" nh-config-file="hibernate.cfg.xml"   />
   7:   </persistantUnits>
   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" />
   3:  </configSections>
   4:  <NHibernate.Burrow >
   5:  <persistantUnits>
   6:    <add name="PersistenceUnitDB1" nh-config-file="db1hibernate.cfg.xml" />
   7:    <add name="PersistenceUnitDB2" nh-config-file="db2hibernate.cfg.xml" />
   8:  </persistantUnits>
   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

No comments exist yet for this page.
View More
Powered by Community Server (Commercial Edition), by Telligent Systems