title: Spring Data Rest - Set request timeout
body: <p>I have a <code>Visit</code> entity which refers to a <code>Patient</code> entity by <code>ManyToOne</code> relationship. The repository for <code>Visit</code> is: </p>
  
  <pre><code>@RepositoryRestResource(collectionResourceRel = "visits", path = "visits", excerptProjection=VisitProjection.class)
  public interface VisitRepository extends PagingAndSortingRepository&lt;Visit, Long&gt; {
  
      @RestResource(path="all")
      List&lt;Visit&gt; findByPatientIdContaining(@Param("keyword") String keyword);
  
  }
  </code></pre>
  
  <p>When searching visits by patient ID with <code>/visits/search/all?keyword=1</code> which may return millions of records, the query is forever pending and never ends. In the console there are dozens of hibernate sqls printed every second. <strong>How can I set the request timeout from server side?</strong></p>
  
  <p>I have tried:</p>
  
  <ol>
  <li>And <code>Transactional</code> annotation with timeout attribute to repository method: (works a little but still takes long to timeout)</li>
  </ol>
  
  <blockquote>
  <pre><code>@RestResource(path="all")
  @Transactional(timeout=2)
  List&lt;Visit&gt; findByPatientIdContaining(@Param("keyword") String keyword);
  </code></pre>
  </blockquote>
  
  <ol start="2">
  <li>add some timeout properties to <code>application.properties</code>: (just doesn't work at all):</li>
  </ol>
  
  <blockquote>
  <pre><code>spring.jpa.properties.hibernate.c3p0.timeout=2
  spring.jpa.properties.javax.persistence.query.timeout=2
  spring.mvc.async.request-timeout=2
  server.connection-timeout=2
  rest.connection.connection-request-timeout=2
  rest.connection.connect-timeout=2
  rest.connection.read-timeout=2
  server.servlet.session.timeout=2
  spring.session.timeout=2
  spring.jdbc.template.query-timeout=2
  spring.transaction.default-timeout=2
  spring.jpa.properties.javax.persistence.query.timeout=2
  javax.persistence.query.timeout=2
  server.tomcat.connection-timeout=5
  </code></pre>
  </blockquote>