Class OrmQueryRequest<T>

java.lang.Object
io.ebeaninternal.server.core.BeanRequest
io.ebeaninternal.server.core.OrmQueryRequest<T>
All Implemented Interfaces:
BeanQueryRequest<T>, SpiOrmQueryRequest<T>

public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQueryRequest<T>
Wraps the objects involved in executing a Query.
  • Constructor Details

  • Method Details

    • translate

      public jakarta.persistence.PersistenceException translate(String bindLog, String sql, SQLException e)
    • isGetAllFromBeanCache

      public boolean isGetAllFromBeanCache()
      Description copied from interface: SpiOrmQueryRequest
      Return true if hitting bean cache and returning all beans from cache.
      Specified by:
      isGetAllFromBeanCache in interface SpiOrmQueryRequest<T>
    • isDeleteByStatement

      public boolean isDeleteByStatement()
      Description copied from interface: SpiOrmQueryRequest
      Return true if delete by statement is allowed for this type given cascade rules etc.
      Specified by:
      isDeleteByStatement in interface SpiOrmQueryRequest<T>
    • isPadInExpression

      public boolean isPadInExpression()
      Specified by:
      isPadInExpression in interface BeanQueryRequest<T>
    • isMultiValueIdSupported

      public boolean isMultiValueIdSupported()
      Specified by:
      isMultiValueIdSupported in interface BeanQueryRequest<T>
    • isMultiValueSupported

      public boolean isMultiValueSupported(Class<?> valueType)
      Specified by:
      isMultiValueSupported in interface BeanQueryRequest<T>
    • markNotQueryOnly

      public void markNotQueryOnly()
      Mark the transaction as not being query only.
      Specified by:
      markNotQueryOnly in interface SpiOrmQueryRequest<T>
    • dbLikeClause

      public String dbLikeClause(boolean rawLikeExpression)
      Return the database platform like clause.
      Specified by:
      dbLikeClause in interface SpiOrmQueryRequest<T>
    • escapeLikeString

      public String escapeLikeString(String value)
      Return the database platform escaped like string.
      Specified by:
      escapeLikeString in interface SpiOrmQueryRequest<T>
    • executeSecondaryQueries

      public void executeSecondaryQueries(boolean forEach)
    • secondaryQueriesMinBatchSize

      public int secondaryQueriesMinBatchSize()
      For use with QueryIterator and secondary queries this returns the minimum batch size that should be loaded before executing the secondary queries.

      If -1 is returned then NO secondary queries are registered and simple iteration is fine.

    • descriptor

      public BeanDescriptor<T> descriptor()
      Return the BeanDescriptor for the associated bean.
      Specified by:
      descriptor in interface SpiOrmQueryRequest<T>
    • loadContext

      public LoadContext loadContext()
      Return the graph context for this query.
    • prepareQuery

      public void prepareQuery()
      Prepare the query and calculate the query plan key.
      Specified by:
      prepareQuery in interface SpiOrmQueryRequest<T>
    • isNativeSql

      public boolean isNativeSql()
    • isRawSql

      public boolean isRawSql()
    • createDeployParser

      public DeployParser createDeployParser()
    • persistenceContext

      public PersistenceContext persistenceContext()
      Return the PersistenceContext used for this request.
    • initTransIfRequired

      public void initTransIfRequired()
      This will create a local (readOnly) transaction if no current transaction exists.

      A transaction may have been passed in explicitly or currently be active in the thread local. If not, then a readOnly transaction is created to execute this query.

      Specified by:
      initTransIfRequired in interface SpiOrmQueryRequest<T>
    • rollbackTransIfRequired

      public void rollbackTransIfRequired()
      Rollback the transaction if it was created for this request.
      Overrides:
      rollbackTransIfRequired in class BeanRequest
    • endTransIfRequired

      public void endTransIfRequired()
      Will end a locally created transaction.

      It ends the query only transaction.

      Specified by:
      endTransIfRequired in interface SpiOrmQueryRequest<T>
    • isFindById

      public boolean isFindById()
      Return true if this is a find by id (rather than List Set or Map).
    • isFindIterate

      public boolean isFindIterate()
      Return true if this is a findEach, findIterate type query where we expect many results.
    • delete

      public int delete()
      Description copied from interface: SpiOrmQueryRequest
      Execute the query as a delete.
      Specified by:
      delete in interface SpiOrmQueryRequest<T>
    • update

      public int update()
      Description copied from interface: SpiOrmQueryRequest
      Execute the query as a update.
      Specified by:
      update in interface SpiOrmQueryRequest<T>
    • findResultSet

      public SpiResultSet findResultSet()
      Description copied from interface: SpiOrmQueryRequest
      Execute returning the ResultSet.
      Specified by:
      findResultSet in interface SpiOrmQueryRequest<T>
    • findId

      public Object findId()
      Description copied from interface: SpiOrmQueryRequest
      Execute the query as findById.
      Specified by:
      findId in interface SpiOrmQueryRequest<T>
    • findCount

      public int findCount()
      Description copied from interface: SpiOrmQueryRequest
      Execute the find row count query.
      Specified by:
      findCount in interface SpiOrmQueryRequest<T>
    • findIds

      public <A> List<A> findIds()
      Description copied from interface: SpiOrmQueryRequest
      Execute the find ids query.
      Specified by:
      findIds in interface SpiOrmQueryRequest<T>
    • findEach

      public void findEach(Consumer<T> consumer)
      Description copied from interface: SpiOrmQueryRequest
      Execute findEach iterating results one bean at a time.
      Specified by:
      findEach in interface SpiOrmQueryRequest<T>
    • findEach

      public void findEach(int batch, Consumer<List<T>> batchConsumer)
      Description copied from interface: SpiOrmQueryRequest
      Execute findEach with a batch consumer.
      Specified by:
      findEach in interface SpiOrmQueryRequest<T>
    • findEachWhile

      public void findEachWhile(Predicate<T> consumer)
      Description copied from interface: SpiOrmQueryRequest
      Execute the find returning a QueryIterator and visitor pattern.
      Specified by:
      findEachWhile in interface SpiOrmQueryRequest<T>
    • findIterate

      public QueryIterator<T> findIterate()
      Description copied from interface: SpiOrmQueryRequest
      Execute the find returning a QueryIterator.
      Specified by:
      findIterate in interface SpiOrmQueryRequest<T>
    • findList

      public List<T> findList()
      Description copied from interface: SpiOrmQueryRequest
      Execute the query as findList.
      Specified by:
      findList in interface SpiOrmQueryRequest<T>
    • findVersions

      public List<Version<T>> findVersions()
      Description copied from interface: SpiOrmQueryRequest
      Execute the finVersions() query.
      Specified by:
      findVersions in interface SpiOrmQueryRequest<T>
    • findSet

      public Set<T> findSet()
      Description copied from interface: SpiOrmQueryRequest
      Execute the query as findSet.
      Specified by:
      findSet in interface SpiOrmQueryRequest<T>
    • findMap

      public <K> Map<K,T> findMap()
      Description copied from interface: SpiOrmQueryRequest
      Execute the query as findMap.
      Specified by:
      findMap in interface SpiOrmQueryRequest<T>
    • findSingleAttributeCollection

      public <A extends Collection<?>> A findSingleAttributeCollection(A collection)
      Description copied from interface: SpiOrmQueryRequest
      Execute the findSingleAttributeCollection query.
      Specified by:
      findSingleAttributeCollection in interface SpiOrmQueryRequest<T>
    • finder

      public BeanFindController finder()
      Return a bean specific finder if one has been set.
    • query

      public SpiQuery<T> query()
      Description copied from interface: SpiOrmQueryRequest
      Return the query.
      Specified by:
      query in interface BeanQueryRequest<T>
      Specified by:
      query in interface SpiOrmQueryRequest<T>
    • determineMany

      public BeanPropertyAssocMany<?> determineMany()
      Determine and return the ToMany property that is included in the query.
    • manyPropertyForOrderBy

      public BeanPropertyAssocMany<?> manyPropertyForOrderBy()
      Return the many property that is fetched in the query or null if there is not one.
    • queryPlan

      public CQueryPlan queryPlan()
      Return a queryPlan for the current query if one exists. Returns null if no query plan for this query exists.
    • queryPlanKey

      public CQueryPlanKey queryPlanKey()
      Return the queryPlanHash.

      This identifies the query plan for a given bean type. It effectively matches a SQL statement with ? bind variables. A query plan can be reused with just the bind variables changing.

    • putQueryPlan

      public void putQueryPlan(CQueryPlan queryPlan)
      Put the QueryPlan into the cache.
    • resetBeanCacheAutoMode

      public void resetBeanCacheAutoMode(boolean findOne)
      Description copied from interface: SpiOrmQueryRequest
      Reset Bean cache mode AUTO - require explicit setting for bean cache use with findList().
      Specified by:
      resetBeanCacheAutoMode in interface SpiOrmQueryRequest<T>
    • isQueryCachePut

      public boolean isQueryCachePut()
    • isBeanCachePutMany

      public boolean isBeanCachePutMany()
    • isBeanCachePut

      public boolean isBeanCachePut()
    • mergeCacheHits

      public void mergeCacheHits(BeanCollection<T> result)
      Merge in prior L2 bean cache hits with the query result.
    • beanCacheHits

      public List<T> beanCacheHits()
      Description copied from interface: SpiOrmQueryRequest
      Return the bean cache hits (when all hits / no misses).
      Specified by:
      beanCacheHits in interface SpiOrmQueryRequest<T>
    • beanCacheHitsAsMap

      public <K> Map<K,T> beanCacheHitsAsMap()
      Description copied from interface: SpiOrmQueryRequest
      Return the bean cache hits for findMap (when all hits / no misses).
      Specified by:
      beanCacheHitsAsMap in interface SpiOrmQueryRequest<T>
    • beanCacheHitsAsSet

      public Set<T> beanCacheHitsAsSet()
      Description copied from interface: SpiOrmQueryRequest
      Return the bean cache hits for findMap (when all hits / no misses).
      Specified by:
      beanCacheHitsAsSet in interface SpiOrmQueryRequest<T>
    • getFromBeanCache

      public boolean getFromBeanCache()
      Description copied from interface: SpiOrmQueryRequest
      Maybe hit the bean cache returning true if everything was obtained from the cache (that there were no misses).

      Do this for findList() on many natural keys or many Ids.

      Specified by:
      getFromBeanCache in interface SpiOrmQueryRequest<T>
    • getFromQueryCache

      public Object getFromQueryCache()
      Try to get the query result from the query cache.
      Specified by:
      getFromQueryCache in interface SpiOrmQueryRequest<T>
    • putToQueryCache

      public void putToQueryCache(Object result)
    • setCancelableQuery

      public void setCancelableQuery(CancelableQuery cancelableQuery)
      Set a Query object that owns the PreparedStatement that can be cancelled.
    • logSql

      public void logSql(String msg, Object... args)
      Log the SQL if the logLevel is appropriate.
    • lazyLoadBatchSize

      public int lazyLoadBatchSize()
      Return the batch size for lazy loading on this bean query request.
    • baseTableAlias

      public String baseTableAlias()
      Return the base table alias for this query.
    • setDefaultFetchBuffer

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

      public Object tenantId()
      Return the tenantId associated with this request.
    • slowQueryCheck

      public void slowQueryCheck(long executionTimeMicros, int rowCount)
      Check for slow query event.
    • setInlineCountDistinct

      public void setInlineCountDistinct()
    • isInlineCountDistinct

      public boolean isInlineCountDistinct()
    • addDependentTables

      public void addDependentTables(Set<String> tables)
    • isInlineSqlUpdateLimit

      public boolean isInlineSqlUpdateLimit()
      Return true if no MaxRows or use LIMIT in SQL update.
    • forwardOnlyFetchSize

      public int forwardOnlyFetchSize()
    • clearContext

      public void clearContext()