title: hibernate with spring-boot does not release the connection after a org.hibernate.ScrollableResults
body: <p>Goodmorning everyone,</p>
  
  <p>I have an Soap Endpoint built via SpringBoot 1.5.8.RELEASE (java 8) that connects to a database ORACLE12C and returns some data sets. For some methods I used JpaRepository while for other queries I created the query via javax.persistence.criteria.CriteriaBuilder instantiated via javax.persistence.EntityManager.getCriteriaBuilder() (EntityManager is @Autowired via spring).</p>
  
  <p>I noticed that, once the 100 requests were exceeded, the connection pool stopped making connections (<strong><em>[http-nio-80-exec-4] Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none available[size:100; busy:100; idle:0; lastwait:30000].</em></strong>) in a particular case: the case in which 100 requests had been executed involving an object of type org.hibernate.ScrollableResults.</p>
  
  <pre><code>ScrollableResults scroll = em.createQuery(cq).setHint(QueryHints.HINT_FETCH_SIZE, max).unwrap(org.hibernate.Query.class).scroll(ScrollMode.FORWARD_ONLY);
  List&lt;Document&gt; list = new ArrayList&lt;&gt;(max);
  for (int i = 0; scroll.next() &amp;&amp; i &lt; max; i++) {
      list.add((Document) scroll.get(0));
  }
  scroll.close();
  </code></pre>
  
  <p>after reading around some examples and documentation that did not lead to the solution, I did a test trying to translate the code as follows:</p>
  
  <pre><code>List&lt;Document&gt; list = em.createQuery(cq).setFirstResult(0).setMaxResults(max).getResultList();
  </code></pre>
  
  <p>and all works fine; however I need to keep the "scroll" mode and all the various experiments have failed.</p>
  
  <p>I tried to play with the "spring.datasource.tomcat" properties without success.</p>
  
  <p>can someone help me ?</p>