Hi all, am new to NHibernate. When performing below test took 11.2 seconds (debug mode) i am seeing this large startup time in all my tests (basically creating the first session takes a ton of time)
setup = Windows 2003 SP2 / Oracle10gR2 latest CPU / ODP.net 2.111.7.20 / FNH 1.0.0.636 / NHibernate 2.1.2.4000 / NUnit 2.5.2.9222 / VS2008 SP1
using System;
using System.Collections;
using System.Data;
using System.Globalization;
using System.IO;
using System.Text;
using System.Data;
using NUnit.Framework;
using System.Collections.Generic;
using System.Data.Common;
using NHibernate;
using log4net.Config;
using System.Configuration;
using FluentNHibernate;
[Test()]
public void GetEmailById()
{
Email result;
using (EmailRepository repository = new EmailRepository())
{
results = repository.GetById(1111);
}
Assert.IsTrue(results != null);
}
//In my Repository
public T GetById(object id)
{
using (var session = sessionFactory.OpenSession())
using (var transaction = session.BeginTransaction())
{
try
{
T returnVal = session.Get<T>(id);
transaction.Commit();
return returnVal;
}
catch (HibernateException ex)
{
// Logging here
transaction.Rollback();
return null;
}
}
}
The query time is very small. The resulting entity is really small. Subsequent queries are fine.
Its seems to be getting the first session started.
Has anyone else seen something similar?
edit1 :
public RepositoryBase()
{
config = Fluently.Configure()
.Database(OracleClientConfiguration.Oracle10
.ConnectionString(c => c.FromConnectionStringWithKey("DBCONSTRING"))
.Driver<NHibernate.Driver.OracleDataClientDriver>().ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<MYASSEM>())
.BuildConfiguration();
sessionFactory = config.BuildSessionFactory();
}