title: hibernate exception: transaction roll back failed
body: <p>When im running my hibernate project in java swing, it works at first. but when i wait for some time and i recieve error like  org.hibernate.TransactionException: rollback failed.. tell me a solution for this.</p>
  
  <p>Here is my error</p>
  
  <pre><code>Aug 16, 2013 10:52:21 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  WARN: SQL Error: 0, SQLState: 08S01
  Aug 16, 2013 10:52:21 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  ERROR: Communications link failure
  The last packet successfully received from the server was 89,371 milliseconds ago. 
  The last packet sent successfully to the server was 1 milliseconds ago.
  Exception in thread "AWT-EventQueue-0" org.hibernate.TransactionException: rollback  failed
  at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.rollback(AbstractTransactionImpl.java:215) at com.softroniics.queenpharma.services.PurchaseOrderService.showAllPurchase(PurchaseOrderService.java:131)
  </code></pre>
  
  <p>Here is my hibernate cfg file</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt; 
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD  3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
      &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://queenpharma.db.11583306.hostedresource.com/queenpharma&lt;/property&gt;
      &lt;property name="connection.username"&gt;queenpharma&lt;/property&gt;
      &lt;property name="connection.password"&gt;Queenpharma#1&lt;/property&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
      &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
      &lt;property name="connection.autocommit"&gt;false&lt;/property&gt;
  
      &lt;property name="hibernate.c3p0.max_size"&gt;1&lt;/property&gt;
      &lt;property name="hibernate.c3p0.min_size"&gt;0&lt;/property&gt;
      &lt;property name="hibernate.c3p0.timeout"&gt;5000&lt;/property&gt;
      &lt;property name="hibernate.c3p0.max_statements"&gt;1000&lt;/property&gt;
      &lt;property name="hibernate.c3p0.idle_test_period"&gt;300&lt;/property&gt;
      &lt;property name="hibernate.c3p0.acquire_increment"&gt;1&lt;/property&gt;
  
      &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
      &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;
      &lt;mapping class="com.softroniics.queenpharma.model.LoginModel" /&gt;
      &lt;mapping class="com.softroniics.queenpharma.model.PurchaseCompanyModel" /&gt;
  </code></pre>
  
  <p>---- and so on------</p>
  
  <p>here is some my code</p>
  
  <pre><code>        session = sessionFactory.openSession();
      StockModel stockModel = null;
      try {
          tx = session.beginTransaction();
          Iterator&lt;StockModel&gt; iterator = session
                  .createQuery("FROM StockModel where productid='" + id + "'")
                  .list().iterator();
          if(iterator.hasNext()){
          stockModel = iterator.next();
          }
  
      } catch (HibernateException e) {
          if (tx != null)
              tx.rollback();
          e.printStackTrace();
      } finally {
           session.close();
  </code></pre>