Interface SpiQuery<T>

All Superinterfaces:
CancelableQuery, Query<T>, QueryBuilder<Query<T>,T>, QueryBuilderProjection<Query<T>,T>, SpiCancelableQuery, SpiQueryFetch, TxnProfileEventCodes
All Known Implementing Classes:
DefaultOrmQuery

public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCodes, SpiCancelableQuery
Object Relational query - Internal extension to Query object.
  • Method Details

    • profileEventId

      String profileEventId()
      Return the profile event id based on query mode and type.
    • profileId

      String profileId()
      Return the id used to identify a particular query for the given bean type.
    • profileLocation

      ProfileLocation profileLocation()
      Return the profile location for this query.
    • hint

      String hint()
      Return the SQL hint to include in the query.
    • label

      String label()
      Return the label set on the query.
    • planLabel

      String planLabel()
      Return the label manually set on the query or from the profile location.
    • transaction

      SpiTransaction transaction()
      Return the transaction explicitly assigned or null.
    • isUseMaster

      boolean isUseMaster()
      Return true if this query should not use the read only data source.
    • isFindById

      boolean isFindById()
      Return true if this is a "find by id" query. This includes a check for a single "equal to" expression for the Id.
    • isFindAll

      boolean isFindAll()
      Return true if this is a "find all" query. Used to set a "find all" profile location if necessary.
    • isAutoTunable

      boolean isAutoTunable()
      Return true if AutoTune should be attempted on this query.
    • isNativeSql

      boolean isNativeSql()
      Return true if this is a native sql query.
    • nativeSql

      String nativeSql()
      Return the unmodified native sql query (with named params etc).
    • getForUpdateLockWait

      Query.LockWait getForUpdateLockWait()
      Return the ForUpdate mode.
      Specified by:
      getForUpdateLockWait in interface Query<T>
    • descriptor

      BeanDescriptor<T> descriptor()
      Return the bean descriptor for this query.
    • queryPlanKey

      Object queryPlanKey()
      Return the query plan key.
    • rawSql

      SpiRawSql rawSql()
      Return the RawSql that was set to use for this query.
    • persistenceContextScope

      PersistenceContextScope persistenceContextScope()
      Return the PersistenceContextScope that this query should use.

      This can be null and in that case use the default scope.

    • getOriginKey

      String getOriginKey()
      Return the origin key.
    • lazyLoadBatchSize

      int lazyLoadBatchSize()
      Return the default lazy load batch size.
    • selectAllForLazyLoadProperty

      void selectAllForLazyLoadProperty()
      Return true if select all properties was used to ensure the property invoking a lazy load was included in the query.
    • selectProperties

      void selectProperties(OrmQueryProperties other)
      Set the select properties.
    • fetchProperties

      void fetchProperties(String path, OrmQueryProperties other)
      Set the fetch properties for the given path.
    • setProfilePath

      void setProfilePath(String label, String relativePath, @Nullable ProfileLocation profileLocation)
      Set the on a secondary query given the label, relativePath and profile location of the parent query.
    • setMode

      void setMode(SpiQuery.Mode m)
      Set the query mode.
    • mode

      Return the query mode.
    • temporalMode

      SpiQuery.TemporalMode temporalMode()
      Return the Temporal mode for the query.
    • isVersionsBetween

      boolean isVersionsBetween()
      Return true if this is a find versions between query.
    • versionStart

      Timestamp versionStart()
      Return the find versions start timestamp.
    • versionEnd

      Timestamp versionEnd()
      Return the find versions end timestamp.
    • isAsOfQuery

      boolean isAsOfQuery()
      Return true if this is a 'As Of' query.
    • isIncludeSoftDeletes

      boolean isIncludeSoftDeletes()
      Return true if this query includes soft deleted rows.
    • getAsOf

      Timestamp getAsOf()
      Return the asOf Timestamp which the query should run as.
    • isAsOfBaseTable

      boolean isAsOfBaseTable()
      Return true if the base table is using history.
    • setAsOfBaseTable

      void setAsOfBaseTable()
      Set when the base table is using history.
    • incrementAsOfTableCount

      void incrementAsOfTableCount()
      Increment the counter of tables used in 'As Of' query.
    • incrementAsOfTableCount

      void incrementAsOfTableCount(int asOfTableCount)
      Increment the counter of tables used in 'As Of' query.
    • getAsOfTableCount

      int getAsOfTableCount()
      Return the table alias used for the base table.
    • addSoftDeletePredicate

      void addSoftDeletePredicate(String softDeletePredicate)
    • softDeletePredicates

      List<String> softDeletePredicates()
    • setArrayParameter

      void setArrayParameter(String name, Collection<?> values)
      Bind the named multi-value array parameter which we would use with Postgres ANY.
    • copy

      SpiQuery<T> copy()
      Return a copy of the query.

      Note that this does NOT copy the forUpdate property. See #2762.

      Specified by:
      copy in interface QueryBuilder<Query<T>,T>
    • distinctOn

      String distinctOn()
      Return the distinct on clause.
    • copy

      SpiQuery<T> copy(SpiEbeanServer server)
      Return a copy of the query attaching to a different EbeanServer.
    • type

      Return the type of query (List, Set, Map, Bean, rowCount etc).
    • setType

      void setType(SpiQuery.Type type)
      Set the query type (List, Set etc).
    • loadDescription

      String loadDescription()
      Return a more detailed description of the lazy or query load.
    • loadMode

      String loadMode()
      Return the load mode (+lazy or +query).
    • setLazyLoadForParents

      void setLazyLoadForParents(BeanPropertyAssocMany<?> many)
      This becomes a lazy loading query for a many relationship.
    • lazyLoadMany

      BeanPropertyAssocMany<?> lazyLoadMany()
      Return the lazy loading 'many' property.
    • setLoadDescription

      void setLoadDescription(String loadMode, String loadDescription)
      Set the load mode (+lazy or +query) and the load description.
    • checkNamedParameters

      void checkNamedParameters()
      Check that the named parameters have had their values set.
    • createNamedParameter

      SpiNamedParam createNamedParameter(String parameterName)
      Create a named parameter placeholder.
    • manyWhereJoins

      ManyWhereJoins manyWhereJoins()
      Return the joins required to support predicates on the many properties.
    • resetBeanCacheAutoMode

      void resetBeanCacheAutoMode(boolean findOne)
      Reset AUTO mode to OFF for findList(). Expect explicit cache use with findList().
    • cacheIdLookup

      CacheIdLookup<T> cacheIdLookup()
      Bean cache lookup for find by ids.
    • naturalKey

      NaturalKeyQueryData<T> naturalKey()
      Collect natural key data for this query or null if the query does not match the requirements of natural key lookup.
    • naturalKeyBindParam

      NaturalKeyBindParam naturalKeyBindParam()
      Return a Natural Key bind parameter if supported by this query.
    • setupForDeleteOrUpdate

      void setupForDeleteOrUpdate()
      Set the query to be a delete query.
    • setDeleteByIdsPlan

      CQueryPlanKey setDeleteByIdsPlan()
      Set the query to be delete by ids due to cascading delete.
    • setSelectId

      void setSelectId()
      Set the query to select the id property only.
    • setSingleAttribute

      void setSingleAttribute()
      Mark the query as selecting a single attribute.
    • isSingleAttribute

      boolean isSingleAttribute()
      Return true if this is singleAttribute query.
    • isWithId

      boolean isWithId()
      Return true if the query should include the Id property.

      distinct and single attribute queries exclude the Id property.

    • setFilterMany

      void setFilterMany(String prop, ExpressionList<?> filterMany)
      Set a filter to a join path.
    • setTenantId

      void setTenantId(Object tenantId)
      Set the tenantId to use for lazy loading.
    • tenantId

      Object tenantId()
      Return the tenantId to use for lazy loading.
    • setLazyLoadManyPath

      void setLazyLoadManyPath(String lazyLoadManyPath)
      Set the path of the many when +query/+lazy loading query is executed.
    • convertJoins

      SpiQueryManyJoin convertJoins()
      Convert joins as necessary to query joins etc.
    • secondaryQuery

      SpiQuerySecondary secondaryQuery()
      Return secondary queries if required.
    • persistenceContext

      PersistenceContext persistenceContext()
      Return the TransactionContext.

      If no TransactionContext is present on the query then the TransactionContext from the Transaction is used (transaction scoped persistence context).

    • setPersistenceContext

      void setPersistenceContext(PersistenceContext transactionContext)
      Set an explicit TransactionContext (typically for a refresh query).

      If no TransactionContext is present on the query then the TransactionContext from the Transaction is used (transaction scoped persistence context).

    • isDetailEmpty

      boolean isDetailEmpty()
      Return true if the query detail has neither select or joins specified.
    • isAutoTune

      Boolean isAutoTune()
      Return explicit AutoTune setting or null. If null then not explicitly set so we use the default behaviour.
    • profilingListener

      ProfilingListener profilingListener()
      If return null then no profiling for this query. If a ProfilingListener is returned this implies that profiling is turned on for this query (and all the objects this query creates).
    • setProfilingListener

      void setProfilingListener(ProfilingListener manager)
      This has the effect of turning on profiling for this query.
    • setOrigin

      ObjectGraphNode setOrigin(CallOrigin callOrigin)
      Return the origin point for the query.

      This MUST be call prior to a query being changed via tuning. This is because the queryPlanHash is used to identify the query point.

    • setParentNode

      void setParentNode(ObjectGraphNode node)
      Set the profile point of the bean or collection that is lazy loading.

      This enables use to hook this back to the original 'root' query by the queryPlanHash and stackPoint.

    • setLazyLoadProperty

      void setLazyLoadProperty(String lazyLoadProperty)
      Set the property that invoked the lazy load and MUST be included in the lazy loading query.
    • lazyLoadProperty

      String lazyLoadProperty()
      Return the property that invoked lazy load.
    • parentNode

      ObjectGraphNode parentNode()
      Used to hook back a lazy loading query to the original query (query point).

      This will return null or an "original" query.

    • usingFuture

      void usingFuture()
      Set that this is a future query that will execute in the background.
    • isUsingFuture

      boolean isUsingFuture()
      Return true if this is a future query.
    • isUsageProfiling

      boolean isUsageProfiling()
      Return false when this is a lazy load or refresh query for a bean.

      We just take/copy the data from those beans and don't collect AutoTune usage profiling on those lazy load or refresh beans.

    • setUsageProfiling

      void setUsageProfiling(boolean usageProfiling)
      Set to false if this query should not be included in the AutoTune usage profiling information.
    • prepare

      CQueryPlanKey prepare(SpiOrmQueryRequest<T> request)
      Prepare the query which prepares sub-query expressions and calculates and returns the query plan key.

      The query plan excludes actual bind values (as they don't effect the query plan).

    • queryBindKey

      void queryBindKey(BindValuesKey key)
      Build the key for the bind values used in the query (for l2 query cache).

      Combined with queryPlanHash() to return queryHash (a unique key for a query).

    • queryHash

      HashQuery queryHash()
      Identifies queries that are exactly the same including bind variables.
    • isRawSql

      boolean isRawSql()
      Return true if this is a RawSql query.
    • checkPagingOrderBy

      boolean checkPagingOrderBy()
      Return true if the query should have an order by appended automatically.
    • orderByIsEmpty

      boolean orderByIsEmpty()
      Return true if there is no Order By clause.
    • getOrderBy

      OrderBy<T> getOrderBy()
      Return the Order By clause or null if there is none defined.
    • whereExpressions

      SpiExpressionList<T> whereExpressions()
      Can return null if no expressions where added to the where clause.
    • havingExpressions

      SpiExpressionList<T> havingExpressions()
      Can return null if no expressions where added to the having clause.
    • hasMaxRowsOrFirstRow

      boolean hasMaxRowsOrFirstRow()
      Returns true if either firstRow or maxRows has been set.
    • isBeanCacheGet

      boolean isBeanCacheGet()
      Return true if the query should GET against bean cache.
    • isBeanCachePut

      boolean isBeanCachePut()
      Return true if the query should PUT against the bean cache.
    • isForceHitDatabase

      boolean isForceHitDatabase()
      Return true if we must hit the DB (Cache reload or select for update).
    • beanCacheMode

      CacheMode beanCacheMode()
      Return the cache mode for using the bean cache (Get and Put).
    • queryCacheMode

      CacheMode queryCacheMode()
      Return the cache mode if this query should use/check the query cache.
    • isUnmodifiable

      boolean isUnmodifiable()
      Return true if the beans returned by this query should be unmodifiable.
    • timeout

      int timeout()
      Return the query timeout.
    • bindParams

      BindParams bindParams()
      Return the bind parameters.
    • initBindParams

      BindParams initBindParams()
      Return the bind parameters ensuring it is initialised.
    • setDetail

      void setDetail(OrmQueryDetail detail)
      Replace the query detail. This is used by the AutoTune feature to as a fast way to set the query properties and joins.

      Note care must be taken to keep the where, orderBy, firstRows and maxRows held in the detail attributes.

    • tuneFetchProperties

      boolean tuneFetchProperties(OrmQueryDetail detail)
      AutoTune tune the detail specifying properties to select on already defined joins and adding extra joins where they are missing.
    • setAutoTuned

      void setAutoTuned(boolean autoTuned)
      Set to true if this query has been tuned by autoTune.
    • detail

      OrmQueryDetail detail()
      Return the query detail.
    • m2mIncludeJoin

      TableJoin m2mIncludeJoin()
      Return the extra join for a M2M lazy load.
    • setM2MIncludeJoin

      void setM2MIncludeJoin(TableJoin includeTableJoin)
      Set the extra join for a M2M lazy load.
    • mapKey

      String mapKey()
      Return the property used to specify keys for a map.
    • getMaxRows

      int getMaxRows()
      Return the maximum number of rows to return in the query.
      Specified by:
      getMaxRows in interface Query<T>
    • getFirstRow

      int getFirstRow()
      Return the index of the first row to return in the query.
      Specified by:
      getFirstRow in interface Query<T>
    • isDisableLazyLoading

      boolean isDisableLazyLoading()
      Return true if lazy loading has been disabled on the query.
    • isDistinct

      boolean isDistinct()
      Return true if this query has been specified by a user to use DISTINCT.
    • isManualId

      boolean isManualId()
      Return true if the Id property is manually included in the query (DTO queries).
    • setManualId

      void setManualId()
      Set to true when we only include the Id property if it is explicitly included in the select().
    • setDefaultSelectClause

      void setDefaultSelectClause()
      Set default select clauses where none have been explicitly defined.
    • setGeneratedSql

      void setGeneratedSql(String generatedSql)
      Set the generated sql for debug purposes.
    • setDefaultFetchBuffer

      void setDefaultFetchBuffer(int fetchSize)
      Set the JDBC fetchSize buffer hint if not explicitly set.
    • bufferFetchSizeHint

      int bufferFetchSizeHint()
      Return the hint for Statement.setFetchSize().
    • baseTable

      String baseTable()
      Return the base table to use if user defined on the query.
    • alias

      String alias()
      Return root table alias set by QueryBuilder.alias(String) command.
    • getAlias

      String getAlias(String defaultAlias)
      Return root table alias with default option.
    • validate

      Set<String> validate(BeanType<T> desc)
      Validate the query returning the set of properties with unknown paths.
    • updateProperties

      OrmUpdateProperties updateProperties()
      Return the properties for an update query.
    • simplifyExpressions

      void simplifyExpressions()
      Simplify nested expression lists where possible.
    • countDistinctOrder

      CountDistinctOrder countDistinctOrder()
      Returns the count distinct order setting.
    • handleLoadError

      void handleLoadError(String fullName, Exception e)
      Handles load errors.