From 1047c63f3cce6d109261c19cd9abbbde97e1426e Mon Sep 17 00:00:00 2001 From: James Agnew Date: Fri, 16 Jun 2017 10:35:39 -0400 Subject: [PATCH] Add missing commit for JPA maximum fetch size --- .../ca/uhn/fhir/jpa/dao/SearchBuilder.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java index a723bd9682a..e2d6223fa51 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java @@ -43,16 +43,7 @@ import org.hl7.fhir.instance.model.api.*; import com.google.common.collect.*; -import ca.uhn.fhir.context.BaseRuntimeChildDefinition; -import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition; -import ca.uhn.fhir.context.BaseRuntimeElementDefinition; -import ca.uhn.fhir.context.ConfigurationException; -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.context.RuntimeChildChoiceDefinition; -import ca.uhn.fhir.context.RuntimeChildResourceDefinition; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.context.RuntimeSearchParam; +import ca.uhn.fhir.context.*; import ca.uhn.fhir.jpa.dao.data.IForcedIdDao; import ca.uhn.fhir.jpa.dao.data.IResourceIndexedSearchParamUriDao; import ca.uhn.fhir.jpa.entity.*; @@ -1253,7 +1244,7 @@ public class SearchBuilder implements ISearchBuilder { return new QueryIterator(); } - private TypedQuery createQuery(SortSpec sort) { + private TypedQuery createQuery(SortSpec sort, Integer theMaximumResults) { CriteriaQuery outerQuery; /* * Sort @@ -1366,6 +1357,11 @@ public class SearchBuilder implements ISearchBuilder { * Now perform the search */ final TypedQuery query = myEntityManager.createQuery(outerQuery); + + if (theMaximumResults != null) { + query.setMaxResults(theMaximumResults); + } + return query; } @@ -2031,7 +2027,9 @@ public class SearchBuilder implements ISearchBuilder { // If we don't have a query yet, create one if (myResultsIterator == null) { - final TypedQuery query = createQuery(mySort); + Integer maximumResults = myCallingDao.getConfig().getFetchSizeDefaultMaximum(); + + final TypedQuery query = createQuery(mySort, maximumResults); myResultsIterator = query.getResultList().iterator(); // If the query resulted in extra results being requested