I have a Visit
entity which refers to a Patient
entity by ManyToOne
relationship. The repository for Visit
is:
@RepositoryRestResource(collectionResourceRel = "visits", path = "visits", excerptProjection=VisitProjection.class)
public interface VisitRepository extends PagingAndSortingRepository<Visit, Long> {
@RestResource(path="all")
List<Visit> findByPatientIdContaining(@Param("keyword") String keyword);
}
When searching visits by patient ID with /visits/search/all?keyword=1
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. How can I set the request timeout from server side?
I have tried:
- And
Transactional
annotation with timeout attribute to repository method: (works a little but still takes long to timeout)
@RestResource(path="all") @Transactional(timeout=2) List<Visit> findByPatientIdContaining(@Param("keyword") String keyword);
- add some timeout properties to
application.properties
: (just doesn't work at all):
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