Class DelegatingQuery

    • Constructor Detail

      • DelegatingQuery

        public DelegatingQuery​(Query query)
        Constructor; supply delegate.
    • Method Detail

      • getDelegate

        public Query getDelegate()
        Return the direct delegate.
      • getInnermostDelegate

        public Query getInnermostDelegate()
        Return the native delegate.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • translate

        protected java.lang.RuntimeException translate​(java.lang.RuntimeException re)
        Translate the OpenJPA exception.
      • getBroker

        public Broker getBroker()
        Description copied from interface: Query
        The broker that generated this query.
        Specified by:
        getBroker in interface Query
      • getQuery

        public Query getQuery()
        Description copied from interface: QueryContext
        Return the query for this context. Note that the query will be unavailable in remote contexts, and this method may throw an exception to that effect.
        Specified by:
        getQuery in interface QueryContext
      • getLanguage

        public java.lang.String getLanguage()
        Description copied from interface: QueryContext
        The query language.
        Specified by:
        getLanguage in interface QueryContext
      • getIgnoreChanges

        public boolean getIgnoreChanges()
        Description copied from interface: QueryContext
        Whether to ignore changes in the current transaction.
        Specified by:
        getIgnoreChanges in interface QueryContext
      • getCompilation

        public java.lang.Object getCompilation()
        Description copied from interface: QueryContext
        Return the query's compilation state.
        Specified by:
        getCompilation in interface QueryContext
      • getAlias

        public java.lang.String getAlias()
        Description copied from interface: QueryContext
        If this query is not a projection but places candidate results into a result class under an alias, return that alias.
        Specified by:
        getAlias in interface QueryContext
      • getProjectionAliases

        public java.lang.String[] getProjectionAliases()
        Description copied from interface: QueryContext
        If this query is a projection, return the projection aliases.
        Specified by:
        getProjectionAliases in interface QueryContext
      • getProjectionTypes

        public java.lang.Class[] getProjectionTypes()
        Description copied from interface: QueryContext
        If this query is a projection, return the projection types.
        Specified by:
        getProjectionTypes in interface QueryContext
      • isAggregate

        public boolean isAggregate()
        Description copied from interface: QueryContext
        Return true if the query is an aggregate.
        Specified by:
        isAggregate in interface QueryContext
      • hasGrouping

        public boolean hasGrouping()
        Description copied from interface: QueryContext
        Return true if the query uses grouping.
        Specified by:
        hasGrouping in interface QueryContext
      • getFilterListeners

        public java.util.Collection getFilterListeners()
        Description copied from interface: QueryContext
        The set of filter listeners.
        Specified by:
        getFilterListeners in interface QueryContext
      • getCandidateCollection

        public java.util.Collection getCandidateCollection()
        Description copied from interface: QueryContext
        Return the candidate collection, or null if an extent was specified instead of a collection.
        Specified by:
        getCandidateCollection in interface QueryContext
      • getCandidateType

        public java.lang.Class getCandidateType()
        Description copied from interface: QueryContext
        Return the class of the objects that this query will return, or null if this information is not available / not relevant.
        Specified by:
        getCandidateType in interface QueryContext
      • hasSubclasses

        public boolean hasSubclasses()
        Description copied from interface: QueryContext
        Whether query results will include subclasses of the candidate class.
        Specified by:
        hasSubclasses in interface QueryContext
      • setCandidateType

        public void setCandidateType​(java.lang.Class cls,
                                     boolean subs)
        Description copied from interface: QueryContext
        Set the candidate type.
        Specified by:
        setCandidateType in interface QueryContext
      • isReadOnly

        public boolean isReadOnly()
        Description copied from interface: QueryContext
        Whether the query has been marked read-only.
        Specified by:
        isReadOnly in interface QueryContext
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
        Description copied from interface: QueryContext
        Whether the query has been marked read-only.
        Specified by:
        setReadOnly in interface QueryContext
      • getResultMappingScope

        public java.lang.Class getResultMappingScope()
        Description copied from interface: QueryContext
        Scope of a mapping from the result data to its object representation.
        Specified by:
        getResultMappingScope in interface QueryContext
      • getResultMappingName

        public java.lang.String getResultMappingName()
        Description copied from interface: QueryContext
        Name of a mapping from the result data to its object representation.
        Specified by:
        getResultMappingName in interface QueryContext
      • setResultMapping

        public void setResultMapping​(java.lang.Class scope,
                                     java.lang.String name)
        Description copied from interface: QueryContext
        Name and scope of a mapping from the result data to its object representation.
        Specified by:
        setResultMapping in interface QueryContext
      • setUnique

        public void setUnique​(boolean unique)
        Description copied from interface: QueryContext
        Specify that the query will return only 1 result, rather than a collection. The execute method will return null if the query result size is 0.
        Specified by:
        setUnique in interface QueryContext
      • isDistinct

        public boolean isDistinct()
        Description copied from interface: QueryContext
        Affirms if this query results are distinct instance(s).
        Specified by:
        isDistinct in interface QueryContext
      • setResultType

        public void setResultType​(java.lang.Class cls)
        Description copied from interface: QueryContext
        Specify the type of object in which the result of evaluating this query.
        Specified by:
        setResultType in interface QueryContext
      • getStartRange

        public long getStartRange()
        Description copied from interface: QueryContext
        Return the 0-based start index for the returned results.
        Specified by:
        getStartRange in interface QueryContext
      • getEndRange

        public long getEndRange()
        Description copied from interface: QueryContext
        Return the 0-based exclusive end index for the returned results, or Long.MAX_VALUE for no limit.
        Specified by:
        getEndRange in interface QueryContext
      • setRange

        public void setRange​(long start,
                             long end)
        Description copied from interface: QueryContext
        Set the range of results to return.
        Specified by:
        setRange in interface QueryContext
        Parameters:
        start - 0-based inclusive start index
        end - 0-based exclusive end index, or Long.MAX_VALUE for no limit
      • getOrderedParameterTypes

        public OrderedMap<java.lang.Object,​java.lang.Class<?>> getOrderedParameterTypes()
        Description copied from interface: QueryContext
        Return a map of parameter name to type for this query. The returned map will iterate in the order that the parameters were declared or, if they're implicit, used.
        Specified by:
        getOrderedParameterTypes in interface QueryContext
      • getParameterTypes

        public LinkedMap getParameterTypes()
        Description copied from interface: QueryContext
        Return a map of parameter name to type for this query. The returned map will iterate in the order that the parameters were declared or, if they're implicit, used.
        Specified by:
        getParameterTypes in interface QueryContext
      • declareParameters

        public void declareParameters​(java.lang.String params)
        Description copied from interface: QueryContext
        Declared parameters, for query languages that use them.
        Specified by:
        declareParameters in interface QueryContext
      • classForName

        public java.lang.Class classForName​(java.lang.String name,
                                            java.lang.String[] imports)
        Description copied from interface: QueryContext
        Helper method to instantiate the class with the given name, taking into account the query's candidate package, automatic imports, and the given imports (if any). Returns null if the type cannot be found.
        Specified by:
        classForName in interface QueryContext
      • lock

        public void lock()
        Description copied from interface: QueryContext
        Synchronize on the query's internal lock.
        Specified by:
        lock in interface QueryContext
      • unlock

        public void unlock()
        Description copied from interface: QueryContext
        Unlock the query's internal lock.
        Specified by:
        unlock in interface QueryContext
      • addFilterListener

        public void addFilterListener​(FilterListener listener)
        Description copied from interface: Query
        Register a filter listener for the query.
        Specified by:
        addFilterListener in interface Query
      • removeFilterListener

        public void removeFilterListener​(FilterListener listener)
        Description copied from interface: Query
        Remove a filter listener from the query.
        Specified by:
        removeFilterListener in interface Query
      • getCandidateExtent

        public Extent getCandidateExtent()
        Description copied from interface: Query
        Return the candidate extent, or null if a collection was specified instead of an extent.
        Specified by:
        getCandidateExtent in interface Query
      • setCandidateExtent

        public void setCandidateExtent​(Extent extent)
        Description copied from interface: Query
        Set the candidate extent.
        Specified by:
        setCandidateExtent in interface Query
      • setCandidateCollection

        public void setCandidateCollection​(java.util.Collection coll)
        Description copied from interface: Query
        Set a collection of candidates.
        Specified by:
        setCandidateCollection in interface Query
      • compile

        public void compile()
        Description copied from interface: Query
        Compile the query.
        Specified by:
        compile in interface Query
      • execute

        public java.lang.Object execute()
        Description copied from interface: Query
        Execute.
        Specified by:
        execute in interface Query
      • execute

        public java.lang.Object execute​(java.util.Map params)
        Description copied from interface: Query
        Execute with parameter map.
        Specified by:
        execute in interface Query
      • execute

        public java.lang.Object execute​(java.lang.Object[] params)
        Description copied from interface: Query
        Execute with parameter array.
        Specified by:
        execute in interface Query
      • deleteAll

        public long deleteAll()
        Description copied from interface: Query
        Deletes all of the instances that are satisfied by the query.
        Specified by:
        deleteAll in interface Query
        Returns:
        the number of instances that were deleted
      • deleteAll

        public long deleteAll​(java.lang.Object[] parameters)
        Description copied from interface: Query
        Deletes all of the instances that are satisfied by the query.
        Specified by:
        deleteAll in interface Query
        Parameters:
        parameters - the positional parameters for the query
        Returns:
        the number of instances that were deleted
      • deleteAll

        public long deleteAll​(java.util.Map parameterMap)
        Description copied from interface: Query
        Deletes all of the instances that are satisfied by the query.
        Specified by:
        deleteAll in interface Query
        Parameters:
        parameterMap - the named parameter map
        Returns:
        the number of instances that were deleted
      • updateAll

        public long updateAll()
        Description copied from interface: Query
        Performs an update of the instances that are satisfied by the query.
        Specified by:
        updateAll in interface Query
        Returns:
        the number of instances that were update
      • updateAll

        public long updateAll​(java.lang.Object[] parameters)
        Description copied from interface: Query
        Performs an update of the instances that are satisfied by the query.
        Specified by:
        updateAll in interface Query
        Parameters:
        parameters - the positional parameter array
        Returns:
        the number of instances that were update
      • updateAll

        public long updateAll​(java.util.Map parameterMap)
        Description copied from interface: Query
        Performs an update of the instances that are satisfied by the query.
        Specified by:
        updateAll in interface Query
        Parameters:
        parameterMap - the named parameter map
        Returns:
        the number of instances that were update
      • closeAll

        public void closeAll()
        Description copied from interface: Query
        Close all open query results.
        Specified by:
        closeAll in interface Query
      • closeResources

        public void closeResources()
        Description copied from interface: Query
        Close query results that are consuming resources. Allow results that are not consuming resources to remain open so that they continue to function normally.
        Specified by:
        closeResources in interface Query
      • getDataStoreActions

        public java.lang.String[] getDataStoreActions​(java.util.Map params)
        Description copied from interface: Query
        Returns a description of the commands that will be sent to the datastore in order to execute this query. This will typically be in the native query language of the database (e.g., SQL).
        Specified by:
        getDataStoreActions in interface Query
        Parameters:
        params - the named parameter map for the query invocation
      • setQuery

        public boolean setQuery​(java.lang.Object query)
        Description copied from interface: Query
        The query string or template.
        Specified by:
        setQuery in interface Query
      • setIgnoreChanges

        public void setIgnoreChanges​(boolean ignore)
        Description copied from interface: Query
        Whether to ignore changes in the current transaction.
        Specified by:
        setIgnoreChanges in interface Query
      • assertOpen

        public void assertOpen()
        Description copied from interface: Query
        Assert that the query's broker is still open.
        Specified by:
        assertOpen in interface Query
      • assertNotReadOnly

        public void assertNotReadOnly()
        Description copied from interface: Query
        Assert that the query is not read-only.
        Specified by:
        assertNotReadOnly in interface Query
      • assertNotSerialized

        public void assertNotSerialized()
        Description copied from interface: Query
        Check that the query has not been serialized, which causes it to lose its association with its Broker.
        Specified by:
        assertNotSerialized in interface Query