Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 196537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:46:33+00:00 2026-05-11T16:46:33+00:00

I have an NHibernate Transaction that does some work and makes a call to

  • 0

I have an NHibernate Transaction that does some work and makes a call to a legacy method which uses DBTransactions to call several Stored Procedures. If any of these legacy method calls fail then the NHibernate Transaction should rollback.

The problem is that the Legacy methods are using data in the database that the NHibernate transaction is creating. This is causing the Legacy code’s SQL Process to lock while waiting on the Nhibernate process. The Nhibernate process is waiting on the Legacy SQL process to finish thus causing a deadlock.

I have tried using ReadUncommitted for both transactions but that doesn’t work.

I tried setting up a Distributed Transaction by using System.EnterpriseServices as recommended in the NHibernate in Action but that doesn’t seem to work either.

I’m not really sure where to go from here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:46:33+00:00Added an answer on May 11, 2026 at 4:46 pm

    You can do one of a few things in desending order of preference.

    1. If your NHibernate work comes first (in terms of execution order), you need to make your legacy methods use your NHibernate database connection. The ISession exposes a Connection property which you could pass to your legacy ADO code.

    2. Or vice versa if this is easier. As long as they are sharing the same connection you will be able to execute both sets of data access in the same transaction context. The ISessionFactory.OpenSession() has an overload that takes and IDbConnection instance.

    3. Start an ambient implicit transaction before you start either legacy methods, or NHibernate methods. When you have finished with both your Nhibernate and legacy code, you can commit them both at the same time by completing the ambient transaction. (I am only putting this 3rd because it will probably take you longer to implement than 1 or 2) See MSDN for how to dow this.

    4. If you get really stuck and are using SQL Server you can do this, but it’s really nasty. You can unite the two separate connections into the same database transaction. I can’t find a link on how to do this just yet, so post back if you are desparate enough to try it!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a servlet that does some work for user and then decrement user's
During my apprenticeship, I have used NHibernate for some smaller projects which I mostly
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have an NHibernate Dao..lets call it MyClassDao for want of a better name.
Ok, so I have an nHibernate ICriteria that returns an object. I want to
I have looked at NHibernate and EntitySpaces and they both seem to work differently.
I have learned so much from http://www.summerofnhibernate.com/ nhibernate screen casts that i wonder why
I'm trying to achieve some kind of nested transaction behavior using NHibernate's transaction control
So, I have an app that uses a SQL Server express db. I have
I have an NHibernate session. In this session, I am performing exactly 1 operation,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.