title: After a few same hql query the application freezes
body: <p>I  am calling below function with the same <strong>batchNumber</strong> and it is working without problem 15 times and takes the records from database without problem but at 16. time the application freezes when the <strong>query.list()</strong> row is called. and not writes "<strong>after query</strong>" (see System.out row) It just loses debug focus and not give any exception. This problem probably is not about the hql because I've seen this problem before different hql and I used criteria instead of hql and I got pass this problem. But for this when I used "<strong>group by</strong>" in criteria(setProjection....)  it doesn't return the result as hibernate model(object) just returns a list. But I need the results as model. </p>
  
  <p>Note: about 15 times it is just for test. This is a web aplication and user may click the button many times that calls this function to see the taken records from database.</p>
  
  <p><em>SiteAddressDaoImpl</em>:</p>
  
  <pre><code>public class SiteAddressDaoImpl&lt;T, Id extends Serializable&gt; extends
          GenericDaoHibernateImpl implements SiteAddressDao {
      public List&lt;SiteAddressModel&gt; getSitesByBatch(String batchNumber) {
          try {
              List&lt;SiteAddressModel&gt; siteList;
              MigrationPlanDao migrationPlanDao = ServiceFactory
                      .getO2SiteService().getMigrationPlanDao();
              Query query = this.getSession().createQuery(
                      "from " + persistentClass.getName() + " where "
                              + "siteType =:" + "type and  siteName in "
                              + "(select distinct exchange from "
                              + migrationPlanDao.getPersistentClass().getName()
                              + " where migrationBatchNumber =:" + "batchNumber"
                              + ")");
              query.setString("batchNumber", batchNumber);
              query.setString("type", "LLU/ASN");
              System.out.println("before query");
  
              siteList = query.list();
              System.out.println("after query");
              return siteList;
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      ...
  }
  </code></pre>
  
  <p><em>GenericDaoHibernateImpl</em>:</p>
  
  <pre><code>public class GenericDaoHibernateImpl&lt;T, Id extends Serializable&gt; extends HibernateDaoSupport implements GenericDao&lt;T, Id&gt; {..........}
  </code></pre>
  
  <p>Hibernate Properties</p>
  
  <pre><code> &lt;!-- Hibernate SessionFactory Definition --&gt;
  &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
        depends-on="annotatedClassRegistrar"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  
      &lt;property name="annotatedClasses" ref="annotatedClassList"/&gt;
  
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="c3p0.acquire_increment"&gt;1&lt;/prop&gt;
              &lt;prop key="c3p0.idle_test_period"&gt;120&lt;/prop&gt;
              &lt;prop key="c3p0.max_size"&gt;50&lt;/prop&gt;
              &lt;prop key="c3p0.max_statements"&gt;0&lt;/prop&gt;
              &lt;prop key="c3p0.min_size"&gt;20&lt;/prop&gt;
              &lt;prop key="c3p0.timeout"&gt;0&lt;/prop&gt;
              &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;
              &lt;prop key="hibernate.cglib.use_reflection_optimizer"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.connection.autocommit"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.HashtableCacheProvider&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;!-- Spring Data Access Exception Translator Defintion --&gt;
  &lt;bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
      &lt;property name="exceptionTranslator" ref="jdbcExceptionTranslator"/&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  &lt;/bean&gt;
  
    &lt;!-- Hibernate Template Defintion --&gt;
  &lt;bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;property name="jdbcExceptionTranslator" ref="jdbcExceptionTranslator"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>beans for a daos</p>
  
  <pre><code>    &lt;bean name="migrationPlanDao"
        class="com.alcatel.lucent.tr.o2ccm.middleware.dao.impl.MigrationPlanDaoImpl"&gt;
      &lt;constructor-arg value="com.alcatel.lucent.tr.o2ccm.middleware.model.hibernate.MigrationPlanModel"/&gt;
      &lt;property name="hibernateTemplate" ref="hibernateTemplate"/&gt;
  &lt;/bean&gt;
  
       &lt;bean name="siteAddressDao" class="com.alcatel.lucent.tr.o2ccm.middleware.dao.impl.SiteAddressDaoImpl"&gt;
      &lt;constructor-arg value="com.alcatel.lucent.tr.o2ccm.middleware.model.hibernate.SiteAddressModel"/&gt;
      &lt;property name="hibernateTemplate" ref="hibernateTemplate"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p><strong>I made the hql simply</strong> </p>
  
  <pre><code> Query query = this.getSession().createQuery("from " + persistentClass.getName() +  " where " +  "siteName='siteName'");
  </code></pre>
  
  <p>it didn't worked at <strong>16th</strong> query.</p>
  
  <p>I used <strong>criteria</strong> instance of hql, that makes the same job as the hql. It worked what is the difference ...</p>
  
  <pre><code>DetachedCriteria criteria = DetachedCriteria.forClass(persistentClass);
  criteria.add(Property.forName("siteName").eq("siteName"));        
  
  siteList = getHibernateTemplate().findByCriteria(criteria);      
  </code></pre>
  
  <p>Hibernate version 3.2.0.ga</p>
  
  <p><strong>Updated</strong>: I added some details.</p>