Class JDOQLTypedQueryImpl<T>

java.lang.Object
org.datanucleus.api.jdo.query.AbstractJDOQLTypedQuery<T>
org.datanucleus.api.jdo.query.JDOQLTypedQueryImpl<T>
All Implemented Interfaces:
Closeable, Serializable, AutoCloseable, javax.jdo.JDOQLTypedQuery<T>

public class JDOQLTypedQueryImpl<T> extends AbstractJDOQLTypedQuery<T> implements javax.jdo.JDOQLTypedQuery<T>
Implementation of a JDOQLTypedQuery. Note that a JDOQLTypedQuery only supports named parameters.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • closed

      private boolean closed
    • fetchPlan

      protected JDOFetchPlan fetchPlan
    • ignoreCache

      protected boolean ignoreCache
    • serializeRead

      protected Boolean serializeRead
    • datastoreReadTimeout

      protected Integer datastoreReadTimeout
    • datastoreWriteTimeout

      protected Integer datastoreWriteTimeout
    • extensions

      protected Map<String,Object> extensions
    • candidates

      protected Collection<T> candidates
    • unmodifiable

      boolean unmodifiable
    • parameterExprByName

      protected Map<String,ExpressionImpl> parameterExprByName
      Map of parameter expression keyed by the name.
    • parameterValuesByName

      protected Map<String,Object> parameterValuesByName
      Map of parameters keyed by their name/expression.
    • subqueries

      protected transient Set<JDOQLTypedSubqueryImpl> subqueries
      Set of any subqueries used by this query.
    • internalQueries

      protected transient Set<org.datanucleus.store.query.Query> internalQueries
      Internal queries generated by this typesafe query. Managed so that they can be closed. TODO Use just one?
    • geospatialHelper

      protected transient Object geospatialHelper
  • Constructor Details

    • JDOQLTypedQueryImpl

      public JDOQLTypedQueryImpl(javax.jdo.PersistenceManager pm, Class<T> candidateClass)
      Constructor for a typesafe query.
      Parameters:
      pm - Persistence Manager
      candidateClass - The candidate class
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isClosed

      public boolean isClosed()
      Accessor for whether this Query is closed.
      Returns:
      Whether this Query is closed.
    • close

      public void close(Object result)
      Specified by:
      close in interface javax.jdo.JDOQLTypedQuery<T>
    • closeAll

      public void closeAll()
      Specified by:
      closeAll in interface javax.jdo.JDOQLTypedQuery<T>
    • candidate

      public javax.jdo.query.PersistableExpression candidate()
      Specified by:
      candidate in interface javax.jdo.JDOQLTypedQuery<T>
    • parameter

      public <P> javax.jdo.query.Expression<P> parameter(String name, Class<P> type)
      Specified by:
      parameter in interface javax.jdo.JDOQLTypedQuery<T>
    • stringParameter

      public javax.jdo.query.StringExpression stringParameter(String name)
      Specified by:
      stringParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • characterParameter

      public javax.jdo.query.CharacterExpression characterParameter(String name)
      Specified by:
      characterParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • numericParameter

      public javax.jdo.query.NumericExpression<? extends Number> numericParameter(String name)
      Specified by:
      numericParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • numericParameter

      public <N extends Number> javax.jdo.query.NumericExpression<N> numericParameter(String name, Class<N> type)
      Specified by:
      numericParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • dateParameter

      public javax.jdo.query.DateExpression dateParameter(String name)
      Specified by:
      dateParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • timeParameter

      public javax.jdo.query.TimeExpression timeParameter(String name)
      Specified by:
      timeParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • datetimeParameter

      public javax.jdo.query.DateTimeExpression datetimeParameter(String name)
      Specified by:
      datetimeParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • collectionParameter

      public javax.jdo.query.CollectionExpression collectionParameter(String name)
      Specified by:
      collectionParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • collectionParameter

      public <E> javax.jdo.query.CollectionExpression<Collection<E>,E> collectionParameter(String name, Class<E> elementType)
      Specified by:
      collectionParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • mapParameter

      public javax.jdo.query.MapExpression mapParameter(String name)
      Specified by:
      mapParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • mapParameter

      public <K, V> javax.jdo.query.MapExpression<Map<K,V>,K,V> mapParameter(String name, Class<K> keyType, Class<V> valueType)
      Specified by:
      mapParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • listParameter

      public javax.jdo.query.ListExpression listParameter(String name)
      Specified by:
      listParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • listParameter

      public <E> javax.jdo.query.ListExpression<List<E>,E> listParameter(String name, Class<E> elementType)
      Specified by:
      listParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • variable

      public <V> javax.jdo.query.Expression<V> variable(String name, Class<V> type)
      Specified by:
      variable in interface javax.jdo.JDOQLTypedQuery<T>
    • ifThenElse

      public <V> javax.jdo.query.IfThenElseExpression<V> ifThenElse(Class<V> type, javax.jdo.query.BooleanExpression ifExpr, javax.jdo.query.Expression<V> thenValueExpr, javax.jdo.query.Expression<V> elseValueExpr)
      Specified by:
      ifThenElse in interface javax.jdo.JDOQLTypedQuery<T>
    • ifThenElse

      public <V> javax.jdo.query.IfThenElseExpression<V> ifThenElse(javax.jdo.query.BooleanExpression cond, javax.jdo.query.Expression<V> thenValueExpr, V elseValue)
      Specified by:
      ifThenElse in interface javax.jdo.JDOQLTypedQuery<T>
    • ifThenElse

      public <V> javax.jdo.query.IfThenElseExpression<V> ifThenElse(javax.jdo.query.BooleanExpression cond, V thenValue, javax.jdo.query.Expression<V> elseValueExpr)
      Specified by:
      ifThenElse in interface javax.jdo.JDOQLTypedQuery<T>
    • ifThenElse

      public <V> javax.jdo.query.IfThenElseExpression<V> ifThenElse(javax.jdo.query.BooleanExpression cond, V thenValue, V elseValue)
      Specified by:
      ifThenElse in interface javax.jdo.JDOQLTypedQuery<T>
    • ifThen

      public <V> javax.jdo.query.IfThenElseExpression<V> ifThen(Class<V> type, javax.jdo.query.BooleanExpression cond, javax.jdo.query.Expression<V> thenValueExpr)
      Specified by:
      ifThen in interface javax.jdo.JDOQLTypedQuery<T>
    • ifThen

      public <V> javax.jdo.query.IfThenElseExpression<V> ifThen(javax.jdo.query.BooleanExpression cond, V thenValue)
      Specified by:
      ifThen in interface javax.jdo.JDOQLTypedQuery<T>
    • excludeSubclasses

      public javax.jdo.JDOQLTypedQuery<T> excludeSubclasses()
      Specified by:
      excludeSubclasses in interface javax.jdo.JDOQLTypedQuery<T>
    • includeSubclasses

      public javax.jdo.JDOQLTypedQuery<T> includeSubclasses()
      Specified by:
      includeSubclasses in interface javax.jdo.JDOQLTypedQuery<T>
    • filter

      public javax.jdo.JDOQLTypedQuery<T> filter(javax.jdo.query.BooleanExpression expr)
      Specified by:
      filter in interface javax.jdo.JDOQLTypedQuery<T>
    • groupBy

      public javax.jdo.JDOQLTypedQuery<T> groupBy(javax.jdo.query.Expression... exprs)
      Specified by:
      groupBy in interface javax.jdo.JDOQLTypedQuery<T>
    • having

      public javax.jdo.JDOQLTypedQuery<T> having(javax.jdo.query.Expression expr)
      Specified by:
      having in interface javax.jdo.JDOQLTypedQuery<T>
    • orderBy

      public javax.jdo.JDOQLTypedQuery<T> orderBy(javax.jdo.query.OrderExpression... exprs)
      Specified by:
      orderBy in interface javax.jdo.JDOQLTypedQuery<T>
    • range

      public javax.jdo.JDOQLTypedQuery<T> range(long lowerIncl, long upperExcl)
      Specified by:
      range in interface javax.jdo.JDOQLTypedQuery<T>
    • range

      public javax.jdo.JDOQLTypedQuery<T> range(javax.jdo.query.NumericExpression lowerInclExpr, javax.jdo.query.NumericExpression upperExclExpr)
      Specified by:
      range in interface javax.jdo.JDOQLTypedQuery<T>
    • range

      public javax.jdo.JDOQLTypedQuery<T> range(javax.jdo.query.Expression paramLowerInclExpr, javax.jdo.query.Expression paramUpperExclExpr)
      Specified by:
      range in interface javax.jdo.JDOQLTypedQuery<T>
    • subquery

      public <S> javax.jdo.JDOQLTypedSubquery<S> subquery(Class<S> candidateClass, String candidateAlias)
      Specified by:
      subquery in interface javax.jdo.JDOQLTypedQuery<T>
    • subquery

      public javax.jdo.JDOQLTypedSubquery<T> subquery(String candidateAlias)
      Specified by:
      subquery in interface javax.jdo.JDOQLTypedQuery<T>
    • subquery

      public <E> javax.jdo.JDOQLTypedSubquery<E> subquery(javax.jdo.query.CollectionExpression<Collection<E>,E> candidateCollection, Class<E> candidateClass, String candidateAlias)
      Specified by:
      subquery in interface javax.jdo.JDOQLTypedQuery<T>
    • setParameters

      public javax.jdo.JDOQLTypedQuery<T> setParameters(Map namedParamMap)
      Specified by:
      setParameters in interface javax.jdo.JDOQLTypedQuery<T>
    • setParameter

      public javax.jdo.JDOQLTypedQuery<T> setParameter(javax.jdo.query.Expression paramExpr, Object value)
      Specified by:
      setParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • setParameter

      public javax.jdo.JDOQLTypedQuery<T> setParameter(String paramName, Object value)
      Specified by:
      setParameter in interface javax.jdo.JDOQLTypedQuery<T>
    • setCandidates

      public javax.jdo.JDOQLTypedQuery<T> setCandidates(Collection<T> candidates)
      Specified by:
      setCandidates in interface javax.jdo.JDOQLTypedQuery<T>
    • result

      public javax.jdo.JDOQLTypedQuery<T> result(boolean distinct, javax.jdo.query.Expression<?>... exprs)
      Specified by:
      result in interface javax.jdo.JDOQLTypedQuery<T>
    • executeResultList

      public <R> List<R> executeResultList(Class<R> resultCls)
      Specified by:
      executeResultList in interface javax.jdo.JDOQLTypedQuery<T>
    • executeResultUnique

      public <R> R executeResultUnique(Class<R> resultCls)
      Specified by:
      executeResultUnique in interface javax.jdo.JDOQLTypedQuery<T>
    • executeResultList

      public List executeResultList()
      Specified by:
      executeResultList in interface javax.jdo.JDOQLTypedQuery<T>
    • executeResultUnique

      public Object executeResultUnique()
      Specified by:
      executeResultUnique in interface javax.jdo.JDOQLTypedQuery<T>
    • executeList

      public List<T> executeList()
      Specified by:
      executeList in interface javax.jdo.JDOQLTypedQuery<T>
    • executeUnique

      public T executeUnique()
      Specified by:
      executeUnique in interface javax.jdo.JDOQLTypedQuery<T>
    • getInternalQuery

      protected org.datanucleus.store.query.Query getInternalQuery()
      Convenience method to generate an internal DataNucleus Query and apply the generic compilation to it.
      Returns:
      The internal DataNucleus query
    • executeInternalQuery

      protected Object executeInternalQuery(org.datanucleus.store.query.Query internalQuery)
    • deletePersistentAll

      public long deletePersistentAll()
      Specified by:
      deletePersistentAll in interface javax.jdo.JDOQLTypedQuery<T>
    • validateParameters

      private void validateParameters()
      Convenience method to validate the defined parameters, and the values provided for these parameters.
      Throws:
      javax.jdo.JDOUserException - if they are inconsistent
    • set

      public javax.jdo.JDOQLTypedQuery<T> set(javax.jdo.query.Expression expr, Object val)
      Method to specify the update of a field of the candidate.
      Parameters:
      expr - Expression for field of the candidate
      val - The new value
      Returns:
      The query
    • update

      public long update()
      Extension method to provide bulk update capabilities (not part of JDO).
      Returns:
      Number of instances that were updated
    • delete

      public long delete()
      Extension method to provide bulk delete capabilities (not part of JDO). This differs from deletePersistentAll() in that it doesn't cascade to related objects (unless the datastore does that automatically), and that it doesn't attempt to update cached objects state to reflect the deletion.
      Returns:
      Number of instances that were deleted
    • getFetchPlan

      public javax.jdo.FetchPlan getFetchPlan()
      Specified by:
      getFetchPlan in interface javax.jdo.JDOQLTypedQuery<T>
    • getPersistenceManager

      public javax.jdo.PersistenceManager getPersistenceManager()
      Specified by:
      getPersistenceManager in interface javax.jdo.JDOQLTypedQuery<T>
    • compile

      public org.datanucleus.store.query.compiler.QueryCompilation compile(org.datanucleus.metadata.MetaDataManager mmgr, org.datanucleus.ClassLoaderResolver clr)
      Method to compile the typesafe query.
      Overrides:
      compile in class AbstractJDOQLTypedQuery<T>
      Parameters:
      mmgr - Metadata manager
      clr - ClassLoader resolver
      Returns:
      The generic compilation
    • getQueryClassNameForClassName

      public static String getQueryClassNameForClassName(String name)
      Method to return the (simple) name of the query class for a specified class name. Currently just returns "Q{className}"
      Parameters:
      name - Simple name of the class (without package)
      Returns:
      Simple name of the query class
    • getDatastoreReadTimeoutMillis

      public Integer getDatastoreReadTimeoutMillis()
      Specified by:
      getDatastoreReadTimeoutMillis in interface javax.jdo.JDOQLTypedQuery<T>
    • datastoreReadTimeoutMillis

      public javax.jdo.JDOQLTypedQuery<T> datastoreReadTimeoutMillis(Integer interval)
      Specified by:
      datastoreReadTimeoutMillis in interface javax.jdo.JDOQLTypedQuery<T>
    • getDatastoreWriteTimeoutMillis

      public Integer getDatastoreWriteTimeoutMillis()
      Specified by:
      getDatastoreWriteTimeoutMillis in interface javax.jdo.JDOQLTypedQuery<T>
    • datastoreWriteTimeoutMillis

      public javax.jdo.JDOQLTypedQuery<T> datastoreWriteTimeoutMillis(Integer interval)
      Specified by:
      datastoreWriteTimeoutMillis in interface javax.jdo.JDOQLTypedQuery<T>
    • getSerializeRead

      public Boolean getSerializeRead()
      Specified by:
      getSerializeRead in interface javax.jdo.JDOQLTypedQuery<T>
    • serializeRead

      public javax.jdo.JDOQLTypedQuery<T> serializeRead(Boolean serialize)
      Specified by:
      serializeRead in interface javax.jdo.JDOQLTypedQuery<T>
    • isUnmodifiable

      public boolean isUnmodifiable()
      Specified by:
      isUnmodifiable in interface javax.jdo.JDOQLTypedQuery<T>
    • unmodifiable

      public javax.jdo.JDOQLTypedQuery<T> unmodifiable()
      Specified by:
      unmodifiable in interface javax.jdo.JDOQLTypedQuery<T>
    • getIgnoreCache

      public boolean getIgnoreCache()
      Specified by:
      getIgnoreCache in interface javax.jdo.JDOQLTypedQuery<T>
    • ignoreCache

      public javax.jdo.JDOQLTypedQuery<T> ignoreCache(boolean flag)
      Specified by:
      ignoreCache in interface javax.jdo.JDOQLTypedQuery<T>
    • extension

      public javax.jdo.JDOQLTypedQuery<T> extension(String key, Object value)
      Specified by:
      extension in interface javax.jdo.JDOQLTypedQuery<T>
    • extensions

      public javax.jdo.JDOQLTypedQuery<T> extensions(Map values)
      Specified by:
      extensions in interface javax.jdo.JDOQLTypedQuery<T>
    • cancelAll

      public void cancelAll()
      Specified by:
      cancelAll in interface javax.jdo.JDOQLTypedQuery<T>
    • cancel

      public void cancel(Thread thread)
      Specified by:
      cancel in interface javax.jdo.JDOQLTypedQuery<T>
    • saveAsNamedQuery

      public javax.jdo.JDOQLTypedQuery<T> saveAsNamedQuery(String name)
      Specified by:
      saveAsNamedQuery in interface javax.jdo.JDOQLTypedQuery<T>
    • getJDOQLForExpression

      public String getJDOQLForExpression(org.datanucleus.store.query.expression.Expression expr)
      Overrides:
      getJDOQLForExpression in class AbstractJDOQLTypedQuery<T>
    • assertIsModifiable

      protected void assertIsModifiable()
      Method to throw an exception if the query is currently not modifiable.
      Throws:
      org.datanucleus.exceptions.NucleusUserException - Thrown when it is unmodifiable
    • assertIsOpen

      protected void assertIsOpen()
      Method to assert if this Query is open.
      Throws:
      javax.jdo.JDOFatalUserException - if the Query is closed.
    • geospatialHelper

      public javax.jdo.query.geospatial.GeospatialHelper geospatialHelper()
      Specified by:
      geospatialHelper in interface javax.jdo.JDOQLTypedQuery<T>