title: Hibernate - Could not obtain transaction-synchronized Session for current thread
body: <p>I understand this question has been asked many time, but most can't explain my problem:</p>
  
  <pre><code>@RequestMapping("/testing")
  public String testing(HttpServletRequest request, final ModelMap model) 
  {
      Transaction ut = session.openSession().beginTransaction();
  
      session.getCurrentSession(); // error here
  
      ut.commit();
  
      return "testing";
  }
  </code></pre>
  
  <p>Why I am getting the error </p>
  
  <pre><code>Could not obtain transaction-synchronized Session for current thread.
  </code></pre>
  
  <p>If I annotate the method with <code>@Transactional</code>, it is working perfectly fine. Because I have <code>@EnableTransactionManagement</code> in my spring context.</p>
  
  <p>I want to try something to understand the difference between <code>getCurrentSession</code>and <code>openSession</code>, so I created test case above.</p>
  
  <p><code>getCurrentSession</code> is called within a active Transaction context, why it is still throwing me error???</p>
  
  <p>Refer the code from <a href="https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/transactions.html" rel="nofollow">this</a>.</p>