Does Nhibernate session.BeginTransaction auto rollback on exception within Using

Viewed 4101

Ok sorry for the long subject name...

If I do the following:

using (var transaction = session.BeginTransaction())
{
    // do something
    transaction.Commit();
}

If my do something caused an exception, would it auto rollback, or do I need to explicitly check for this like below:

using (var transaction = session.BeginTransaction())
{
    try
    {
        // do something
        transaction.Commit();
    }
    catch (Exception)
    {
        transaction.Rollback();
    }
}
1 Answers
Related