More on NHibernate and ITransactionFactory

2 commentsWritten on July 21st, 2007 by
Categories: NHibernate, Software Development

A while ago i submitted a patch to fix the issue i had with NHibernate ignoring the hibernate.transaction_factory setting. The patch has now been committed to the NHibernate subversion repository. The name of the setting has been changed to hibernate.transaction.factory_class though.

So now you can define which ITransactionFactory you want NHibernate to use in your config file, or from code without using my dirty reflection workaround as this test demonstrates:

    [Test]
    public void SettingsTransactionFactoryReturnsConfiguredTransactionFactory()
    {
      Configuration configuration = new Configuration();
      configuration.Properties[Cfg.Environment.TransactionStrategy] =
        "NHibernate.Test.NHSpecificTest.NH1054.DummyTransactionFactory, "
        + this.GetType().Assembly.FullName;

  ISessionFactory sessionFactory = configuration.BuildSessionFactory();

  Assert.IsInstanceOfType(typeof(DummyTransactionFactory),
    sessionFactory.Settings.TransactionFactory);
}

To avoid any confusion: Cfg.Environment.TransactionStrategy is a public string containing "hibernate.transaction.factory_class"

You will need either NHibernate from trunk to use this, or wait for the 1.2.1 release.