title: Is it prohibited to begin() the same transaction after committing it (transaction reuse )?
body: <p>I have this two method in my Database helper class. </p>
  
  <pre><code>public static void beginTransaction()
  {
      if(transaction==null)
      {
          transaction=session.beginTransaction();
      }
      else
      {
          transaction.begin(); //this one
      }
  }
  
  public static void commitTransaction()
  {
      try {
              transaction.commit();
          }
  
      } catch (Exception e) {
          if(transaction!=null)
              transaction.rollback();
  
          closeSession();
          e.printStackTrace();
      }       
  
  }
  </code></pre>
  
  <p>The problem is when <code>commitTransaction()</code> is called after one operation and then <code>beginTransaction()</code> called again for another operation it throws <strong><code>transaction instance is no longer valid</code></strong> exception. And stackTrace indicating to <code>transaction.begin();</code> operation .  </p>
  
  <p><strong>So, Is it prohibited to begin() the same transaction after committing it.?</strong><br>
  Or<br>
  I am doing it in the wrong way?</p>
  
  <p>Note: <code>transaction</code> <code>session</code>  <code>closeSession()</code> they are my class variables and method</p>