title: nhibernate retry how to manage the session in deadlocks
body: <p>I have been having deadlock issues. I've been on working some retry approaches. My retry code is currently just a 'for' statement that tries 5 times. I understand i need to use the 'Evit' nhibernate method to clear the session. I am using a session factory and use a transaction for each request. </p>
  
  <p>In the below example if i experience a deadlock on the first retry will the orderNote property remain the same on the second retry?</p>
  
  <pre><code>private ActionResult OrderDetails(int id)
  {
      var order = _orderRepository.Get(id);
      order.OrderNote = "will this text remain";
  
      Retry.Times(5).Do(() =&gt; _orderRepository.Update(order));
  
      return View();
  }
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>1) Finding it hard to trace the cause. I'm getting about 10 locks a day all over my application.  Just set up a profiler. Are there any other useful methods for tracing</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms190465.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms190465.aspx</a></p>
  
  <p>I think the main issue is that i'm using auto increament. I'm in the process of moving to hilo. </p>
  
  <p>2) Using a different transation mode. I'm not defining any at the moment. What is recommended. </p>
  
  <p>5) Long running operations. Yes i do. And i think because i'm using auto increament lazy loading is ignored. Does that sound correct?</p>