From c9c09a9762445e84cc1bc266ee48fdbe62fb782c Mon Sep 17 00:00:00 2001 From: Michael Buckley Date: Sun, 29 Sep 2024 21:51:56 -0400 Subject: [PATCH] Fix everything sql --- .../uhn/fhir/jpa/search/builder/SearchBuilder.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java index 59ecfa233ae..5ba808fcfe4 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java @@ -121,9 +121,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.SingleColumnRowMapper; +import org.springframework.jdbc.core.RowMapper; import org.springframework.transaction.support.TransactionSynchronizationManager; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -140,7 +142,7 @@ import java.util.stream.Collectors; import static ca.uhn.fhir.jpa.model.util.JpaConstants.UNDESIRED_RESOURCE_LINKAGES_FOR_EVERYTHING_ON_PATIENT_INSTANCE; import static ca.uhn.fhir.jpa.search.builder.QueryStack.LOCATION_POSITION; import static ca.uhn.fhir.jpa.search.builder.QueryStack.SearchForIdsParams.with; -import static ca.uhn.fhir.jpa.util.InClauseNormalizer.*; +import static ca.uhn.fhir.jpa.util.InClauseNormalizer.normalizeIdListForInClause; import static java.util.Objects.requireNonNull; import static org.apache.commons.collections4.CollectionUtils.isNotEmpty; import static org.apache.commons.lang3.StringUtils.defaultString; @@ -799,7 +801,12 @@ public class SearchBuilder implements ISearchBuilder { String sql = allTargetsSql.getSql(); Object[] args = allTargetsSql.getBindVariables().toArray(new Object[0]); - List output = jdbcTemplate.query(sql, args, new SingleColumnRowMapper<>(Long.class)); + List output = jdbcTemplate.query(sql, args, new RowMapper() { + @Override + public Long mapRow(ResultSet rs, int rowNum) throws SQLException { + return rs.getLong(2); + } + }); // we add a search executor to fetch unlinked patients first theSearchQueryExecutors.add(new ResolvedSearchQueryExecutor(output));