From 48a71d66492b49c0f856f2e3b1bd6038dc800624 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Thu, 23 Jan 2020 15:58:13 -0500 Subject: [PATCH] fix npe --- .../ca/uhn/fhir/jpa/dao/SearchBuilder.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 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 ce96ce90e49..188821dad02 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 @@ -148,11 +148,6 @@ public class SearchBuilder implements ISearchBuilder { myDontUseHashesForSearch = myDaoConfig.getDisableHashBasedSearches(); } - @PostConstruct - public void postConstruct() { - myPredicateBuilder = new PredicateBuilder(this, myPredicateBuilderFactory); - } - @Override public void setMaxResultsToFetch(Integer theMaxResultsToFetch) { myMaxResultsToFetch = theMaxResultsToFetch; @@ -192,9 +187,7 @@ public class SearchBuilder implements ISearchBuilder { @Override public Iterator createCountQuery(SearchParameterMap theParams, String theSearchUuid, RequestDetails theRequest) { - myParams = theParams; - myBuilder = myEntityManager.getCriteriaBuilder(); - mySearchUuid = theSearchUuid; + init(theParams, theSearchUuid); TypedQuery query = createQuery(null, null, true, theRequest); return new CountQueryIterator(query); @@ -210,9 +203,7 @@ public class SearchBuilder implements ISearchBuilder { @Override public IResultIterator createQuery(SearchParameterMap theParams, SearchRuntimeDetails theSearchRuntimeDetails, RequestDetails theRequest) { - myParams = theParams; - myBuilder = myEntityManager.getCriteriaBuilder(); - mySearchUuid = theSearchRuntimeDetails.getSearchUuid(); + init(theParams, theSearchRuntimeDetails.getSearchUuid()); if (myPidSet == null) { myPidSet = new HashSet<>(); @@ -221,6 +212,13 @@ public class SearchBuilder implements ISearchBuilder { return new QueryIterator(theSearchRuntimeDetails, theRequest); } + private void init(SearchParameterMap theParams, String theTheSearchUuid) { + myParams = theParams; + myBuilder = myEntityManager.getCriteriaBuilder(); + mySearchUuid = theTheSearchUuid; + myPredicateBuilder = new PredicateBuilder(this, myPredicateBuilderFactory); + } + private TypedQuery createQuery(SortSpec sort, Integer theMaximumResults, boolean theCount, RequestDetails theRequest) { CriteriaQuery outerQuery; /*