Module org.eclipse.persistence.jpa
Class EJBQueryImpl<X>
java.lang.Object
org.eclipse.persistence.internal.jpa.QueryImpl
org.eclipse.persistence.internal.jpa.EJBQueryImpl<X>
- All Implemented Interfaces:
Query
,TypedQuery<X>
,JpaQuery<X>
Concrete JPA query class. The JPA query wraps a DatabaseQuery which is
executed.
-
Field Summary
Fields inherited from class org.eclipse.persistence.internal.jpa.QueryImpl
databaseQuery, entityManager, firstResultIndex, isShared, lockMode, maxResults, parameters, parameterValues, queryName, UNDEFINED
-
Constructor Summary
ModifierConstructorDescriptionEJBQueryImpl
(String jpql, EntityManagerImpl entityManager) Build an EJBQueryImpl based on the given jpql string.EJBQueryImpl
(String queryDescription, EntityManagerImpl entityManager, boolean isNamedQuery) Create an EJBQueryImpl with either a query name or an jpql string.protected
EJBQueryImpl
(EntityManagerImpl entityManager) Base constructor for EJBQueryImpl.EJBQueryImpl
(DatabaseQuery query, EntityManagerImpl entityManager) Create an EJBQueryImpl with a DatabaseQuery. -
Method Summary
Modifier and TypeMethodDescriptionstatic DatabaseQuery
buildEJBQLDatabaseQuery
(String queryName, String jpqlQuery, AbstractSession session, Enum lockMode, Map<String, Object> hints, ClassLoader classLoader) Build a DatabaseQuery from an JPQL string.static DatabaseQuery
buildEJBQLDatabaseQuery
(String jpql, AbstractSession session) Build a DatabaseQuery from an jpql string.static DatabaseQuery
buildSQLDatabaseQuery
(Class<?> resultClass, String sqlString, ClassLoader classLoader, AbstractSession session) Build a ReadAllQuery from a class and sql string.static DatabaseQuery
buildSQLDatabaseQuery
(Class<?> resultClass, String sqlString, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) Build a ReadAllQuery for class and sql string.static DatabaseQuery
buildSQLDatabaseQuery
(String sqlString, ClassLoader classLoader, AbstractSession session) Build a DataReadQuery from a sql string.static DatabaseQuery
buildSQLDatabaseQuery
(String sqlResultSetMappingName, String sqlString, ClassLoader classLoader, AbstractSession session) Build a ResultSetMappingQuery from a sql result set mapping name and sql string.static DatabaseQuery
buildSQLDatabaseQuery
(String sqlResultSetMappingName, String sqlString, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) Build a ResultSetMappingQuery from a sql result set mapping name and sql string.static DatabaseQuery
buildSQLDatabaseQuery
(String sqlString, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) Build a DataReadQuery from a sql string.Non-standard method to return results of a ReadQuery that has a containerPolicy that returns objects as a collection rather than a ListNon-standard method to return results of a ReadQuery that uses a Cursor.Execute a query that returns a single result.setFirstResult
(int startPosition) Set the position of the first result to retrieve.setFlushMode
(FlushModeType flushMode) Set the flush mode type to be used for the query execution.Set an implementation-specific hint.setLockMode
(LockModeType lockMode) Set the lock mode type to be used for the query execution.setMaxResults
(int maxResult) Set the maximum number of results to retrieve.setParameter
(int position, Object value) Bind an argument to a positional parameter.setParameter
(int position, Calendar value, TemporalType temporalType) Bind an instance of java.util.Calendar to a positional parameter.setParameter
(int position, Date value, TemporalType temporalType) Bind an instance of java.util.Date to a positional parameter.setParameter
(Parameter<Calendar> param, Calendar value, TemporalType temporalType) Bind an instance of java.util.Calendar to a Parameter object.setParameter
(Parameter<Date> param, Date value, TemporalType temporalType) Bind an instance of java.util.Date to a Parameter object.<T> TypedQuery
setParameter
(Parameter<T> param, T value) Set the value of a Parameter object.setParameter
(String name, Object value) Bind an argument to a named parameter.setParameter
(String name, Calendar value, TemporalType temporalType) Bind an instance of java.util.Calendar to a named parameter.setParameter
(String name, Date value, TemporalType temporalType) Bind an instance of java.util.Date to a named parameter.toString()
Methods inherited from class org.eclipse.persistence.internal.jpa.QueryImpl
applyArguments, applyHints, cloneSharedQuery, close, convertTemporalType, executeReadQuery, executeUpdate, getActiveSession, getDatabaseQuery, getDatabaseQueryInternal, getDetailedException, getEntityManager, getFirstResult, getFlushMode, getHints, getInternalParameters, getLockMode, getMaxResults, getMaxResultsInternal, getParameter, getParameter, getParameter, getParameter, getParameterId, getParameters, getParameterValue, getParameterValue, getParameterValue, getResultList, getSupportedHints, isBound, isFlushModeAUTO, isValidActualParameter, performPreQueryFlush, processParameters, propagateResultProperties, setAsDataModifyQuery, setAsSQLModifyQuery, setAsSQLReadQuery, setDatabaseQuery, setFirstResultInternal, setHintInternal, setMaxResultsInternal, setParameterInternal, setParameterInternal, setRollbackOnly, throwNonUniqueResultException, throwNoResultException, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.jpa.JpaQuery
getDatabaseQuery, getEntityManager, setDatabaseQuery
Methods inherited from interface jakarta.persistence.Query
executeUpdate, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, isBound, unwrap
Methods inherited from interface jakarta.persistence.TypedQuery
getResultList, getResultStream
-
Constructor Details
-
EJBQueryImpl
Base constructor for EJBQueryImpl. Initializes basic variables. -
EJBQueryImpl
Create an EJBQueryImpl with a DatabaseQuery. -
EJBQueryImpl
Build an EJBQueryImpl based on the given jpql string. -
EJBQueryImpl
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 Details
-
buildEJBQLDatabaseQuery
Build a DatabaseQuery from an jpql string.- Parameters:
session
- the session to get the descriptors for this query for.- Returns:
- a DatabaseQuery representing the given jpql.
-
buildEJBQLDatabaseQuery
public static DatabaseQuery buildEJBQLDatabaseQuery(String queryName, String jpqlQuery, AbstractSession session, Enum lockMode, Map<String, Object> hints, 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 DatabaseQuery buildSQLDatabaseQuery(Class<?> resultClass, String sqlString, ClassLoader classLoader, AbstractSession session) Build a ReadAllQuery from a class and sql string. -
buildSQLDatabaseQuery
public static DatabaseQuery buildSQLDatabaseQuery(Class<?> resultClass, String sqlString, Map<String, Object> hints, ClassLoader classLoader, 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 DatabaseQuery buildSQLDatabaseQuery(String sqlString, ClassLoader classLoader, AbstractSession session) Build a DataReadQuery from a sql string. -
buildSQLDatabaseQuery
public static DatabaseQuery buildSQLDatabaseQuery(String sqlString, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) Build a DataReadQuery from a sql string. -
buildSQLDatabaseQuery
public static DatabaseQuery buildSQLDatabaseQuery(String sqlResultSetMappingName, String sqlString, ClassLoader classLoader, AbstractSession session) Build a ResultSetMappingQuery from a sql result set mapping name and sql string. -
buildSQLDatabaseQuery
public static DatabaseQuery buildSQLDatabaseQuery(String sqlResultSetMappingName, String sqlString, Map<String, Object> hints, ClassLoader classLoader, 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
Set an implementation-specific hint. If the hint name is not recognized, it is silently ignored.- Specified by:
setHint
in interfaceQuery
- Specified by:
setHint
in interfaceTypedQuery<X>
- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if the second argument is not valid for the implementation
-
setLockMode
Set the lock mode type to be used for the query execution.- Specified by:
setLockMode
in interfaceQuery
- Specified by:
setLockMode
in interfaceTypedQuery<X>
- Overrides:
setLockMode
in classQueryImpl
- Throws:
IllegalStateException
- if not a Java Persistence query language SELECT query
-
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 interfaceJpaQuery<X>
- Returns:
- Collection of results
-
getResultCursor
Non-standard method to return results of a ReadQuery that uses a Cursor.- Specified by:
getResultCursor
in interfaceJpaQuery<X>
- Returns:
- Cursor on results, either a CursoredStream, or ScrollableCursor
-
getSingleResult
Execute a query that returns a single result.- Specified by:
getSingleResult
in interfaceQuery
- Specified by:
getSingleResult
in interfaceTypedQuery<X>
- Overrides:
getSingleResult
in classQueryImpl
- Returns:
- the result
- Throws:
EntityNotFoundException
- if there is no resultNonUniqueResultException
- if more than one result
-
setFirstResult
Set the position of the first result to retrieve.- Specified by:
setFirstResult
in interfaceQuery
- Specified by:
setFirstResult
in interfaceTypedQuery<X>
- Overrides:
setFirstResult
in classQueryImpl
- Parameters:
startPosition
- position of the first result, numbered from 0- Returns:
- the same query instance
-
setFlushMode
Set the flush mode type to be used for the query execution.- Specified by:
setFlushMode
in interfaceQuery
- Specified by:
setFlushMode
in interfaceTypedQuery<X>
- Overrides:
setFlushMode
in classQueryImpl
-
setMaxResults
Set the maximum number of results to retrieve.- Specified by:
setMaxResults
in interfaceQuery
- Specified by:
setMaxResults
in interfaceTypedQuery<X>
- Overrides:
setMaxResults
in classQueryImpl
- Returns:
- the same query instance
-
setParameter
Bind an instance of java.util.Calendar to a positional parameter.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Returns:
- the same query instance
-
setParameter
Bind an instance of java.util.Date to a positional parameter.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Returns:
- the same query instance
-
setParameter
Bind an argument to a positional parameter.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Returns:
- the same query instance
-
setParameter
public TypedQuery setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType) Bind an instance of java.util.Calendar to a Parameter object.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if position does not correspond to a parameter of the query
-
setParameter
Bind an instance of java.util.Date to a Parameter object.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Parameters:
param
- object- Returns:
- the same query instance
- Throws:
IllegalArgumentException
- if position does not correspond to a parameter of the query
-
setParameter
Set the value of a Parameter object.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Parameters:
param
- parameter to be setvalue
- parameter value- Returns:
- query instance
- Throws:
IllegalArgumentException
- if parameter does not correspond to a parameter of the query
-
setParameter
Bind an instance of java.util.Calendar to a named parameter.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Returns:
- the same query instance
-
setParameter
Bind an instance of java.util.Date to a named parameter.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Returns:
- the same query instance
-
setParameter
Bind an argument to a named parameter.- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceTypedQuery<X>
- Parameters:
name
- the parameter name- Returns:
- the same query instance
-
toString
-