Class SearchQueryBuilder

java.lang.Object
ca.uhn.fhir.jpa.search.builder.sql.SearchQueryBuilder

public class SearchQueryBuilder extends Object
  • Constructor Details

  • Method Details

    • getFhirContext

      public ca.uhn.fhir.context.FhirContext 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)
      Add and return a predicate builder (or a root query if no root query exists yet) 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)
      Add and return a predicate builder (or a root query if no root query exists yet) 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 a QUANTITY search parameter
    • addQuantityPredicateBuilder

      public QuantityPredicateBuilder addQuantityPredicateBuilder(@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 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)
      Add and return a predicate builder (or a root query if no root query exists yet) for selecting on a _source search parameter
    • addReferencePredicateBuilder

      public ResourceLinkPredicateBuilder addReferencePredicateBuilder(QueryStack theQueryStack, @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 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 reosource 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)
      Add and return a predicate builder (or a root query if no root query exists yet) 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 _tag search parameter
    • addTokenPredicateBuilder

      public TokenPredicateBuilder addTokenPredicateBuilder(@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 TOKEN search parameter
    • 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 :missing search parameter
    • addUriPredicateBuilder

      public UriPredicateBuilder addUriPredicateBuilder(@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 URI search parameter
    • 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)
    • generate

      public GeneratedSql generate(@Nullable Integer theOffset, @Nullable Integer theMaxResultsToFetch)
      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

      public String generatePlaceholder(Object theValue)
      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

      public List<String> generatePlaceholders(Collection<?> theValues)
    • countBindVariables

      public int countBindVariables()
    • setMatchNothing

      public void setMatchNothing()
    • addTable

      public com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable addTable(String theTableName)
    • getPartitionSettings

    • getRequestPartitionId

      public ca.uhn.fhir.interceptor.model.RequestPartitionId getRequestPartitionId()
    • getResourceType

    • getModelConfig

    • addPredicate

      public void addPredicate(@Nonnull com.healthmarketscience.sqlbuilder.Condition theCondition)
    • addPredicateLastUpdated

      public com.healthmarketscience.sqlbuilder.ComboCondition addPredicateLastUpdated(ca.uhn.fhir.rest.param.DateRangeParam theDateRange)
    • addResourceIdsPredicate

      public void addResourceIdsPredicate(List<Long> thePidList)
    • excludeResourceIdsPredicate

      public void excludeResourceIdsPredicate(Set<ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId> theExsitinghPidSetToExclude)
    • 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

      public com.healthmarketscience.sqlbuilder.SelectQuery getSelect()
    • haveAtLeastOnePredicate

      public boolean haveAtLeastOnePredicate()
    • addSortString

      public void addSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending)
    • addSortNumeric

      public void addSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending)
    • addSortDate

      public void addSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theColumnValueNormalized, boolean theAscending)
    • addSortString

      public void addSortString(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theTheAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder)
    • addSortNumeric

      public void addSortNumeric(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theTheAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder)
    • addSortDate

      public void addSortDate(com.healthmarketscience.sqlbuilder.dbspec.basic.DbColumn theTheColumnValueNormalized, boolean theTheAscending, com.healthmarketscience.sqlbuilder.OrderObject.NullOrder theNullOrder)
    • setNeedResourceTableRoot

      public void setNeedResourceTableRoot(boolean theNeedResourceTableRoot)
      If set to true (default is false), force the generated SQL to start with the HFJ_RESOURCE table at the root of the query. This seems to perform better if there are multiple joins on the resource ID table.