Fix #1174 - Prevent serialization exception
This commit is contained in:
parent
5d540d9208
commit
5f29e4fbf3
|
@ -255,7 +255,15 @@ public class DateParam extends BaseParamWithPrefix<DateParam> implements /*IQuer
|
||||||
return b.build();
|
return b.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DateParamDateTimeHolder extends BaseDateTimeDt {
|
public static class DateParamDateTimeHolder extends BaseDateTimeDt {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public DateParamDateTimeHolder() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TemporalPrecisionEnum getDefaultPrecisionForDatatype() {
|
protected TemporalPrecisionEnum getDefaultPrecisionForDatatype() {
|
||||||
return TemporalPrecisionEnum.SECOND;
|
return TemporalPrecisionEnum.SECOND;
|
||||||
|
|
|
@ -2,9 +2,9 @@ package ca.uhn.fhir.jpa.dao.r4;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.config.CaptureQueriesListener;
|
import ca.uhn.fhir.jpa.config.CaptureQueriesListener;
|
||||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.*;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
||||||
import ca.uhn.fhir.jpa.model.entity.*;
|
|
||||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||||
import ca.uhn.fhir.model.api.Include;
|
import ca.uhn.fhir.model.api.Include;
|
||||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||||
|
@ -14,9 +14,9 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||||
import ca.uhn.fhir.rest.param.*;
|
import ca.uhn.fhir.rest.param.*;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
|
import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.engine.jdbc.internal.BasicFormatterImpl;
|
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
@ -56,6 +56,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
|
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
|
||||||
myDaoConfig.setFetchSizeDefaultMaximum(new DaoConfig().getFetchSizeDefaultMaximum());
|
myDaoConfig.setFetchSizeDefaultMaximum(new DaoConfig().getFetchSizeDefaultMaximum());
|
||||||
myDaoConfig.setAllowContainsSearches(new DaoConfig().isAllowContainsSearches());
|
myDaoConfig.setAllowContainsSearches(new DaoConfig().isAllowContainsSearches());
|
||||||
|
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -617,7 +618,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
expect1.setResource(resource);
|
expect1.setResource(resource);
|
||||||
expect1.calculateHashes();
|
expect1.calculateHashes();
|
||||||
|
|
||||||
assertThat("Got: \"" + results.toString()+"\"", results, containsInAnyOrder(expect0, expect1));
|
assertThat("Got: \"" + results.toString() + "\"", results, containsInAnyOrder(expect0, expect1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1063,7 +1064,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
QuantityParam v1 = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, 150, "http://bar", "code1");
|
QuantityParam v1 = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, 150, "http://bar", "code1");
|
||||||
SearchParameterMap map = new SearchParameterMap().setLoadSynchronous(true).add(param, v1);
|
SearchParameterMap map = new SearchParameterMap().setLoadSynchronous(true).add(param, v1);
|
||||||
IBundleProvider result = myObservationDao.search(map);
|
IBundleProvider result = myObservationDao.search(map);
|
||||||
assertThat("Got: "+ toUnqualifiedVersionlessIdValues(result), toUnqualifiedVersionlessIdValues(result), containsInAnyOrder(id1.getValue()));
|
assertThat("Got: " + toUnqualifiedVersionlessIdValues(result), toUnqualifiedVersionlessIdValues(result), containsInAnyOrder(id1.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,7 +1096,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
CompositeParam<TokenParam, QuantityParam> val = new CompositeParam<>(v0, v1);
|
CompositeParam<TokenParam, QuantityParam> val = new CompositeParam<>(v0, v1);
|
||||||
SearchParameterMap map = new SearchParameterMap().setLoadSynchronous(true).add(param, val);
|
SearchParameterMap map = new SearchParameterMap().setLoadSynchronous(true).add(param, val);
|
||||||
IBundleProvider result = myObservationDao.search(map);
|
IBundleProvider result = myObservationDao.search(map);
|
||||||
assertThat("Got: "+ toUnqualifiedVersionlessIdValues(result), toUnqualifiedVersionlessIdValues(result), containsInAnyOrder(id2.getValue()));
|
assertThat("Got: " + toUnqualifiedVersionlessIdValues(result), toUnqualifiedVersionlessIdValues(result), containsInAnyOrder(id2.getValue()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TokenParam v0 = new TokenParam("http://foo", "code1");
|
TokenParam v0 = new TokenParam("http://foo", "code1");
|
||||||
|
@ -1143,6 +1144,40 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #1174
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSearchDateInSavedSearch() {
|
||||||
|
for (int i = 1; i <= 9; i++) {
|
||||||
|
Patient p1 = new Patient();
|
||||||
|
p1.getBirthDateElement().setValueAsString("1980-01-0" + i);
|
||||||
|
String id1 = myPatientDao.create(p1).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
myDaoConfig.setSearchPreFetchThresholds(Lists.newArrayList(3, 6, 10));
|
||||||
|
|
||||||
|
{
|
||||||
|
// Don't load synchronous
|
||||||
|
SearchParameterMap map = new SearchParameterMap();
|
||||||
|
map.setLastUpdated(new DateRangeParam().setUpperBound(new DateParam(ParamPrefixEnum.LESSTHAN, "2022-01-01")));
|
||||||
|
IBundleProvider found = myPatientDao.search(map);
|
||||||
|
Set<String> dates = new HashSet<>();
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
Patient nextResource = (Patient) found.getResources(i, i + 1).get(0);
|
||||||
|
dates.add(nextResource.getBirthDateElement().getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat(dates, hasItems(
|
||||||
|
"1980-01-01",
|
||||||
|
"1980-01-09"
|
||||||
|
));
|
||||||
|
|
||||||
|
assertFalse(map.isLoadSynchronous());
|
||||||
|
assertNull(map.getLoadSynchronousUpTo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #222
|
* #222
|
||||||
*/
|
*/
|
||||||
|
@ -2194,16 +2229,16 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
List<String> queries = CaptureQueriesListener
|
List<String> queries = CaptureQueriesListener
|
||||||
.getLastNQueries()
|
.getLastNQueries()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(t->t.getThreadName().equals("main"))
|
.filter(t -> t.getThreadName().equals("main"))
|
||||||
.filter(t -> t.getSql(false, false).toLowerCase().contains("select"))
|
.filter(t -> t.getSql(false, false).toLowerCase().contains("select"))
|
||||||
.filter(t -> t.getSql(false, false).toLowerCase().contains("token"))
|
.filter(t -> t.getSql(false, false).toLowerCase().contains("token"))
|
||||||
.map(t-> t.getSql(true, true))
|
.map(t -> t.getSql(true, true))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
ourLog.info("Queries:\n {}", queries.stream().findFirst());
|
ourLog.info("Queries:\n {}", queries.stream().findFirst());
|
||||||
|
|
||||||
String searchQuery = queries.get(0);
|
String searchQuery = queries.get(0);
|
||||||
assertEquals(searchQuery,3, StringUtils.countMatches(searchQuery.toUpperCase(), "HFJ_SPIDX_TOKEN"));
|
assertEquals(searchQuery, 3, StringUtils.countMatches(searchQuery.toUpperCase(), "HFJ_SPIDX_TOKEN"));
|
||||||
assertEquals(searchQuery, 5, StringUtils.countMatches(searchQuery.toUpperCase(), "LEFT OUTER JOIN"));
|
assertEquals(searchQuery, 5, StringUtils.countMatches(searchQuery.toUpperCase(), "LEFT OUTER JOIN"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,6 +339,11 @@
|
||||||
of unneccesary joins were introduced to the generated SQL query, harming
|
of unneccesary joins were introduced to the generated SQL query, harming
|
||||||
performance. This has been fixed.
|
performance. This has been fixed.
|
||||||
</action>
|
</action>
|
||||||
|
<action type="fix">
|
||||||
|
A serialization error when performing some searches in the JPA server
|
||||||
|
using data parameters has been fixed. Thanks to GitHub user
|
||||||
|
@PickOneFish for reporting!
|
||||||
|
</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="3.6.0" date="2018-11-12" description="Food">
|
<release version="3.6.0" date="2018-11-12" description="Food">
|
||||||
<action type="add">
|
<action type="add">
|
||||||
|
|
Loading…
Reference in New Issue