Class SearchQueryBuilder
java.lang.Object
ca.uhn.fhir.jpa.search.builder.sql.SearchQueryBuilder
-
Constructor Summary
ConstructorsConstructorDescriptionSearchQueryBuilder(ca.uhn.fhir.context.FhirContext theFhirContext, StorageSettings theStorageSettings, PartitionSettings thePartitionSettings, RequestPartitionId theRequestPartitionId, String theResourceType, SqlObjectFactory theSqlBuilderFactory, HibernatePropertiesProvider theDialectProvider, boolean theCountQuery) Constructor -
Method Summary
Modifier and TypeMethodDescriptionAdd and return a predicate builder (or a root query if no root query exists yet) for selecting on a Composite Unique search parameterAdd and return a predicate builder (or a root query if no root query exists yet) for selecting on a Composite Unique search parameteraddCoordsPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a COORDS search parametervoidaddCustomJoin(com.healthmarketscience.sqlbuilder.SelectQuery.JoinType theJoinType, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theFromTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theToTable, com.healthmarketscience.sqlbuilder.Condition theCondition) addDatePredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a DATE search parameteraddForcedIdPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder for selecting a forced ID.voidaddJoin(com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theFromTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theToTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theFromColumn, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theToColumn) voidaddJoin(com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theFromTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theToTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theFromColumn, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theToColumn, com.healthmarketscience.sqlbuilder.SelectQuery.JoinType theJoinType) addNumberPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a NUMBER search parametervoidaddPredicate(com.healthmarketscience.sqlbuilder.Condition theCondition) com.healthmarketscience.sqlbuilder.ComboConditionaddPredicateLastUpdated(ca.uhn.fhir.rest.param.DateRangeParam theDateRange) addQuantityNormalizedPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) addQuantityPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a QUANTITY search parameteraddReferencePredicateBuilder(QueryStack theQueryStack, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a REFERENCE search parameteraddReferencePredicateBuilderReversed(QueryStack theQueryStack, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a resource link where the source and target are reversed.voidaddResourceIdsPredicate(List<Long> thePidList) addResourceTablePredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on the Resource tableaddSearchParamPresentPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a:missingsearch parametervoidaddSortCoordsNear(CoordsPredicateBuilder theCoordsBuilder, double theLatitudeValue, double theLongitudeValue, boolean theAscending) voidaddSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending) voidaddSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending, boolean theUseAggregate) voidaddSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theTheAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder, boolean theUseAggregate) voidaddSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending) voidaddSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending, boolean theUseAggregate) voidaddSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder, boolean theUseAggregate) voidaddSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending) voidaddSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending, boolean theUseAggregate) voidaddSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theTheAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder, boolean theUseAggregate) addSourcePredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn, com.healthmarketscience.sqlbuilder.SelectQuery.JoinType theJoinType) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a_sourcesearch parameteraddStringPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a STRING search parametercom.healthmarketscience.sqlbuilder.dbspec.basic.DbTableaddTagPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a_tagsearch parameteraddTokenPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a TOKEN search parameteraddUriPredicateBuilder(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a URI search parameterintbindOffsetParameter(List<Object> theBindVariables, Integer theOffset, org.hibernate.dialect.pagination.AbstractLimitHandler theLimitHandler, int theStartOfQueryParameterIndex, boolean theBindLimitParametersFirst) intcom.healthmarketscience.sqlbuilder.BinaryConditioncreateConditionForValueWithComparator(ca.uhn.fhir.rest.param.ParamPrefixEnum theComparator, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumn, Object theValue) Create a predicate builder for selecting on a DATE search parameterCreate a predicate builder for selecting on a NUMBER search parametercom.healthmarketscience.sqlbuilder.ComboConditioncreateOnCondition(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceColumn, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTargetColumn) Create a predicate builder for selecting on a QUANTITY search parametercreateReferencePredicateBuilder(QueryStack theQueryStack) Create a predicate builder for selecting on a REFERENCE search parameterCreate a predicate builder for selecting on a STRING search parameterCreate a predicate builder for selecting on a TOKEN search parameterCreate a predicate builder for selecting on a URI search parametervoidexcludeResourceIdsPredicate(Set<JpaPid> theExistingPidSetToExclude) Generate and return the SQL generated by this buildergeneratePlaceholder(Object theValue) The SQL Builder library has one annoying limitation, which is that it does not use/understand bind variables for its generated SQL.generatePlaceholders(Collection<?> theValues) ca.uhn.fhir.context.FhirContextIf at least one predicate builder already exists, return the last one added to the chain.getOrCreateFirstPredicateBuilder(boolean theIncludeResourceTypeAndNonDeletedFlag) If at least one predicate builder already exists, return the last one added to the chain.getOrCreateResourceTablePredicateBuilder(boolean theIncludeResourceTypeAndNonDeletedFlag) com.healthmarketscience.sqlbuilder.SelectQuerybooleanvoidvoidsetNeedResourceTableRoot(boolean theNeedResourceTableRoot) If set to true (default is false), force the generated SQL to start with theHFJ_RESOURCEtable at the root of the query.
-
Constructor Details
-
SearchQueryBuilder
public SearchQueryBuilder(ca.uhn.fhir.context.FhirContext theFhirContext, StorageSettings theStorageSettings, PartitionSettings thePartitionSettings, RequestPartitionId theRequestPartitionId, String theResourceType, SqlObjectFactory theSqlBuilderFactory, HibernatePropertiesProvider theDialectProvider, boolean theCountQuery) Constructor
-
-
Method Details
-
getFhirContext
-
addComboUniquePredicateBuilder
Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a Composite Unique search parameter -
addComboNonUniquePredicateBuilder
Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a Composite Unique search parameter -
addCoordsPredicateBuilder
public CoordsPredicateBuilder addCoordsPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a COORDS search parameter -
addDatePredicateBuilder
public DatePredicateBuilder addDatePredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a DATE search parameter -
createDatePredicateBuilder
Create a predicate builder for selecting on a DATE search parameter -
addForcedIdPredicateBuilder
public ForcedIdPredicateBuilder addForcedIdPredicateBuilder(@Nonnull com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder for selecting a forced ID. This is only intended for use with sorts so it can not be the root query. -
addNumberPredicateBuilder
public NumberPredicateBuilder addNumberPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a NUMBER search parameter -
createNumberPredicateBuilder
Create a predicate builder for selecting on a NUMBER search parameter -
addResourceTablePredicateBuilder
public ResourceTablePredicateBuilder addResourceTablePredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on the Resource table -
addQuantityPredicateBuilder
public QuantityPredicateBuilder addQuantityPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a QUANTITY search parameter -
createQuantityPredicateBuilder
Create a predicate builder for selecting on a QUANTITY search parameter -
addQuantityNormalizedPredicateBuilder
public QuantityNormalizedPredicateBuilder addQuantityNormalizedPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) -
addSourcePredicateBuilder
public SourcePredicateBuilder addSourcePredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn, com.healthmarketscience.sqlbuilder.SelectQuery.JoinType theJoinType) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a_sourcesearch parameter -
addReferencePredicateBuilder
public ResourceLinkPredicateBuilder addReferencePredicateBuilder(QueryStack theQueryStack, @Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a REFERENCE search parameter -
createReferencePredicateBuilder
Create a predicate builder for selecting on a REFERENCE search parameter -
addReferencePredicateBuilderReversed
public ResourceLinkPredicateBuilder addReferencePredicateBuilderReversed(QueryStack theQueryStack, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a resource link where the source and target are reversed. This is used for _has queries. -
addStringPredicateBuilder
public StringPredicateBuilder addStringPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a STRING search parameter -
createStringPredicateBuilder
Create a predicate builder for selecting on a STRING search parameter -
addTagPredicateBuilder
public TagPredicateBuilder addTagPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a_tagsearch parameter -
addTokenPredicateBuilder
public TokenPredicateBuilder addTokenPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a TOKEN search parameter -
createTokenPredicateBuilder
Create a predicate builder for selecting on a TOKEN search parameter -
addCustomJoin
public void addCustomJoin(com.healthmarketscience.sqlbuilder.SelectQuery.JoinType theJoinType, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theFromTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theToTable, com.healthmarketscience.sqlbuilder.Condition theCondition) -
createOnCondition
public com.healthmarketscience.sqlbuilder.ComboCondition createOnCondition(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceColumn, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTargetColumn) -
addSearchParamPresentPredicateBuilder
public SearchParamPresentPredicateBuilder addSearchParamPresentPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a:missingsearch parameter -
addUriPredicateBuilder
public UriPredicateBuilder addUriPredicateBuilder(@Nullable com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theSourceJoinColumn) Create, add and return a predicate builder (or a root query if no root query exists yet) for selecting on a URI search parameter -
createUriPredicateBuilder
Create a predicate builder for selecting on a URI search parameter -
getSqlBuilderFactory
-
newResourceIdBuilder
-
addJoin
public void addJoin(com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theFromTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theToTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theFromColumn, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theToColumn, com.healthmarketscience.sqlbuilder.SelectQuery.JoinType theJoinType) -
addJoin
public void addJoin(com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theFromTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable theToTable, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theFromColumn, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theToColumn) -
generate
Generate and return the SQL generated by this builder -
bindOffsetParameter
public int bindOffsetParameter(List<Object> theBindVariables, @Nullable Integer theOffset, org.hibernate.dialect.pagination.AbstractLimitHandler theLimitHandler, int theStartOfQueryParameterIndex, boolean theBindLimitParametersFirst) -
getOrCreateFirstPredicateBuilder
If at least one predicate builder already exists, return the last one added to the chain. If none has been selected, create a builder on HFJ_RESOURCE, add it and return it. -
getOrCreateFirstPredicateBuilder
public BaseJoiningPredicateBuilder getOrCreateFirstPredicateBuilder(boolean theIncludeResourceTypeAndNonDeletedFlag) If at least one predicate builder already exists, return the last one added to the chain. If none has been selected, create a builder on HFJ_RESOURCE, add it and return it. -
getOrCreateResourceTablePredicateBuilder
-
getOrCreateResourceTablePredicateBuilder
public ResourceTablePredicateBuilder getOrCreateResourceTablePredicateBuilder(boolean theIncludeResourceTypeAndNonDeletedFlag) -
generatePlaceholder
The SQL Builder library has one annoying limitation, which is that it does not use/understand bind variables for its generated SQL. So we work around this by replacing our contents with a string in the SQL consisting of[random UUID]-[value index]and then -
generatePlaceholders
-
countBindVariables
-
setMatchNothing
-
addTable
-
getPartitionSettings
-
getRequestPartitionId
-
getResourceType
-
getStorageSettings
-
addPredicate
-
addPredicateLastUpdated
public com.healthmarketscience.sqlbuilder.ComboCondition addPredicateLastUpdated(ca.uhn.fhir.rest.param.DateRangeParam theDateRange) -
addResourceIdsPredicate
-
excludeResourceIdsPredicate
-
createConditionForValueWithComparator
public com.healthmarketscience.sqlbuilder.BinaryCondition createConditionForValueWithComparator(ca.uhn.fhir.rest.param.ParamPrefixEnum theComparator, com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumn, Object theValue) -
newChildSqlBuilder
-
getSelect
-
haveAtLeastOnePredicate
-
addSortCoordsNear
public void addSortCoordsNear(CoordsPredicateBuilder theCoordsBuilder, double theLatitudeValue, double theLongitudeValue, boolean theAscending) -
addSortString
public void addSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending) -
addSortString
public void addSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending, boolean theUseAggregate) -
addSortNumeric
public void addSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending) -
addSortNumeric
public void addSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending, boolean theUseAggregate) -
addSortDate
public void addSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending) -
addSortDate
public void addSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending, boolean theUseAggregate) -
addSortString
public void addSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theTheAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder, boolean theUseAggregate) -
addSortNumeric
public void addSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder, boolean theUseAggregate) -
addSortDate
public void addSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theTheAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder, boolean theUseAggregate) -
setNeedResourceTableRoot
If set to true (default is false), force the generated SQL to start with theHFJ_RESOURCEtable at the root of the query.This seems to perform better if there are multiple joins on the resource ID table.
-