Class EJBQueryImpl<X>

  • All Implemented Interfaces:
    javax.persistence.Query, javax.persistence.TypedQuery<X>, JpaQuery<X>

    public class EJBQueryImpl<X>
    extends QueryImpl
    implements JpaQuery<X>
    Concrete JPA query class. The JPA query wraps a DatabaseQuery which is executed.
    • Constructor Detail

      • EJBQueryImpl

        protected EJBQueryImpl​(EntityManagerImpl entityManager)
        Base constructor for EJBQueryImpl. Initializes basic variables.
      • EJBQueryImpl

        public EJBQueryImpl​(org.eclipse.persistence.queries.DatabaseQuery query,
                            EntityManagerImpl entityManager)
        Create an EJBQueryImpl with a DatabaseQuery.
      • EJBQueryImpl

        public EJBQueryImpl​(java.lang.String jpql,
                            EntityManagerImpl entityManager)
        Build an EJBQueryImpl based on the given jpql string.
      • EJBQueryImpl

        public EJBQueryImpl​(java.lang.String queryDescription,
                            EntityManagerImpl entityManager,
                            boolean isNamedQuery)
        Create an EJBQueryImpl with either a query name or an jpql string.
        Parameters:
        isNamedQuery - determines whether to treat the queryDescription as jpql or a query name.
    • Method Detail

      • buildEJBQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildEJBQLDatabaseQuery​(java.lang.String jpql,
                                                                                            org.eclipse.persistence.internal.sessions.AbstractSession session)
        Build a DatabaseQuery from an jpql string.
        Parameters:
        jpql -
        session - the session to get the descriptors for this query for.
        Returns:
        a DatabaseQuery representing the given jpql.
      • buildEJBQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildEJBQLDatabaseQuery​(java.lang.String queryName,
                                                                                            java.lang.String jpqlQuery,
                                                                                            org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                                                            java.lang.Enum lockMode,
                                                                                            java.util.Map<java.lang.String,​java.lang.Object> hints,
                                                                                            java.lang.ClassLoader classLoader)
        Build a DatabaseQuery from an JPQL string.
        Parameters:
        jpqlQuery - the JPQL string.
        session - the session to get the descriptors for this query for.
        hints - a list of hints to be applied to the query.
        Returns:
        a DatabaseQuery representing the given jpql.
      • buildSQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildSQLDatabaseQuery​(java.lang.Class resultClass,
                                                                                          java.lang.String sqlString,
                                                                                          java.lang.ClassLoader classLoader,
                                                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        Build a ReadAllQuery from a class and sql string.
      • buildSQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildSQLDatabaseQuery​(java.lang.Class resultClass,
                                                                                          java.lang.String sqlString,
                                                                                          java.util.Map<java.lang.String,​java.lang.Object> hints,
                                                                                          java.lang.ClassLoader classLoader,
                                                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        Build a ReadAllQuery for class and sql string.
        Parameters:
        hints - a list of hints to be applied to the query.
      • buildSQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildSQLDatabaseQuery​(java.lang.String sqlString,
                                                                                          java.lang.ClassLoader classLoader,
                                                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        Build a DataReadQuery from a sql string.
      • buildSQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildSQLDatabaseQuery​(java.lang.String sqlString,
                                                                                          java.util.Map<java.lang.String,​java.lang.Object> hints,
                                                                                          java.lang.ClassLoader classLoader,
                                                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        Build a DataReadQuery from a sql string.
      • buildSQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildSQLDatabaseQuery​(java.lang.String sqlResultSetMappingName,
                                                                                          java.lang.String sqlString,
                                                                                          java.lang.ClassLoader classLoader,
                                                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        Build a ResultSetMappingQuery from a sql result set mapping name and sql string.
      • buildSQLDatabaseQuery

        public static org.eclipse.persistence.queries.DatabaseQuery buildSQLDatabaseQuery​(java.lang.String sqlResultSetMappingName,
                                                                                          java.lang.String sqlString,
                                                                                          java.util.Map<java.lang.String,​java.lang.Object> hints,
                                                                                          java.lang.ClassLoader classLoader,
                                                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        Build a ResultSetMappingQuery from a sql result set mapping name and sql string.
        Parameters:
        hints - a list of hints to be applied to the query.
      • setHint

        public javax.persistence.TypedQuery<X> setHint​(java.lang.String hintName,
                                                       java.lang.Object value)
        Set an implementation-specific hint. If the hint name is not recognized, it is silently ignored.
        Specified by:
        setHint in interface javax.persistence.Query
        Specified by:
        setHint in interface javax.persistence.TypedQuery<X>
        Parameters:
        hintName -
        value -
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the second argument is not valid for the implementation
      • setLockMode

        public EJBQueryImpl setLockMode​(javax.persistence.LockModeType lockMode)
        Set the lock mode type to be used for the query execution.
        Specified by:
        setLockMode in interface javax.persistence.Query
        Specified by:
        setLockMode in interface javax.persistence.TypedQuery<X>
        Overrides:
        setLockMode in class QueryImpl
        Parameters:
        lockMode -
        Throws:
        java.lang.IllegalStateException - if not a Java Persistence query language SELECT query
      • getResultCollection

        public java.util.Collection getResultCollection()
        Non-standard method to return results of a ReadQuery that has a containerPolicy that returns objects as a collection rather than a List
        Specified by:
        getResultCollection in interface JpaQuery<X>
        Returns:
        Collection of results
      • getResultCursor

        public org.eclipse.persistence.queries.Cursor getResultCursor()
        Non-standard method to return results of a ReadQuery that uses a Cursor.
        Specified by:
        getResultCursor in interface JpaQuery<X>
        Returns:
        Cursor on results, either a CursoredStream, or ScrollableCursor
      • getSingleResult

        public X getSingleResult()
        Execute a query that returns a single result.
        Specified by:
        getSingleResult in interface javax.persistence.Query
        Specified by:
        getSingleResult in interface javax.persistence.TypedQuery<X>
        Overrides:
        getSingleResult in class QueryImpl
        Returns:
        the result
        Throws:
        javax.persistence.EntityNotFoundException - if there is no result
        javax.persistence.NonUniqueResultException - if more than one result
      • setFirstResult

        public EJBQueryImpl setFirstResult​(int startPosition)
        Set the position of the first result to retrieve.
        Specified by:
        setFirstResult in interface javax.persistence.Query
        Specified by:
        setFirstResult in interface javax.persistence.TypedQuery<X>
        Overrides:
        setFirstResult in class QueryImpl
        Parameters:
        startPosition - position of the first result, numbered from 0
        Returns:
        the same query instance
      • setFlushMode

        public EJBQueryImpl setFlushMode​(javax.persistence.FlushModeType flushMode)
        Set the flush mode type to be used for the query execution.
        Specified by:
        setFlushMode in interface javax.persistence.Query
        Specified by:
        setFlushMode in interface javax.persistence.TypedQuery<X>
        Overrides:
        setFlushMode in class QueryImpl
        Parameters:
        flushMode -
      • setMaxResults

        public EJBQueryImpl setMaxResults​(int maxResult)
        Set the maximum number of results to retrieve.
        Specified by:
        setMaxResults in interface javax.persistence.Query
        Specified by:
        setMaxResults in interface javax.persistence.TypedQuery<X>
        Overrides:
        setMaxResults in class QueryImpl
        Parameters:
        maxResult -
        Returns:
        the same query instance
      • setParameter

        public javax.persistence.TypedQuery setParameter​(int position,
                                                         java.util.Calendar value,
                                                         javax.persistence.TemporalType temporalType)
        Bind an instance of java.util.Calendar to a positional parameter.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        position -
        value -
        temporalType -
        Returns:
        the same query instance
      • setParameter

        public javax.persistence.TypedQuery setParameter​(int position,
                                                         java.util.Date value,
                                                         javax.persistence.TemporalType temporalType)
        Bind an instance of java.util.Date to a positional parameter.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        position -
        value -
        temporalType -
        Returns:
        the same query instance
      • setParameter

        public javax.persistence.TypedQuery setParameter​(int position,
                                                         java.lang.Object value)
        Bind an argument to a positional parameter.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        position -
        value -
        Returns:
        the same query instance
      • setParameter

        public javax.persistence.TypedQuery setParameter​(javax.persistence.Parameter<java.util.Calendar> param,
                                                         java.util.Calendar value,
                                                         javax.persistence.TemporalType temporalType)
        Bind an instance of java.util.Calendar to a Parameter object.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        param -
        value -
        temporalType -
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if position does not correspond to a parameter of the query
      • setParameter

        public javax.persistence.TypedQuery setParameter​(javax.persistence.Parameter<java.util.Date> param,
                                                         java.util.Date value,
                                                         javax.persistence.TemporalType temporalType)
        Bind an instance of java.util.Date to a Parameter object.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        param - object
        value -
        temporalType -
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if position does not correspond to a parameter of the query
      • setParameter

        public <T> javax.persistence.TypedQuery setParameter​(javax.persistence.Parameter<T> param,
                                                             T value)
        Set the value of a Parameter object.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        param - parameter to be set
        value - parameter value
        Returns:
        query instance
        Throws:
        java.lang.IllegalArgumentException - if parameter does not correspond to a parameter of the query
      • setParameter

        public javax.persistence.TypedQuery setParameter​(java.lang.String name,
                                                         java.util.Calendar value,
                                                         javax.persistence.TemporalType temporalType)
        Bind an instance of java.util.Calendar to a named parameter.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        name -
        value -
        temporalType -
        Returns:
        the same query instance
      • setParameter

        public javax.persistence.TypedQuery setParameter​(java.lang.String name,
                                                         java.util.Date value,
                                                         javax.persistence.TemporalType temporalType)
        Bind an instance of java.util.Date to a named parameter.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        name -
        value -
        temporalType -
        Returns:
        the same query instance
      • setParameter

        public javax.persistence.TypedQuery setParameter​(java.lang.String name,
                                                         java.lang.Object value)
        Bind an argument to a named parameter.
        Specified by:
        setParameter in interface javax.persistence.Query
        Specified by:
        setParameter in interface javax.persistence.TypedQuery<X>
        Parameters:
        name - the parameter name
        value -
        Returns:
        the same query instance
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class QueryImpl