public class QueryImpl
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected DatabaseQuery |
databaseQuery
Wrapped native query.
|
protected EntityManagerImpl |
entityManager |
protected int |
firstResultIndex |
protected boolean |
isShared
Stores if the wrapped query is shared, and requires cloning before being
changed.
|
protected LockModeType |
lockMode |
protected int |
maxResults |
protected java.util.Map<java.lang.String,<any>> |
parameters |
protected java.util.Map<java.lang.String,java.lang.Object> |
parameterValues |
protected java.lang.String |
queryName |
static int |
UNDEFINED |
| Modifier | Constructor and Description |
|---|---|
|
QueryImpl(DatabaseQuery query,
EntityManagerImpl entityManager)
Create an EJBQueryImpl with a DatabaseQuery.
|
protected |
QueryImpl(EntityManagerImpl entityManager)
Base constructor for EJBQueryImpl.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
applyArguments(StoredProcedureCall call,
DatabaseQuery query)
Define the query arguments based on the procedure call.
|
protected static DatabaseQuery |
applyHints(java.util.Map<java.lang.String,java.lang.Object> hints,
DatabaseQuery query,
java.lang.ClassLoader classLoader,
AbstractSession session)
Set implementation-specific hints.
|
protected void |
cloneSharedQuery()
If the query was from the jpql parse cache it must be cloned before being
modified.
|
void |
close()
This method should be called to close any left over open connection to
the database (if there is one).
|
protected java.lang.Object |
convertTemporalType(java.lang.Object value,
TemporalType type)
Convert the given object to the class represented by the given temporal
type.
|
protected java.lang.Object |
executeReadQuery()
Execute a ReadQuery by assigning the stored parameter values and running
it in the database
|
int |
executeUpdate()
Execute an update or delete statement.
|
protected Session |
getActiveSession() |
DatabaseQuery |
getDatabaseQuery()
Return the wrapped
DatabaseQuery ensuring that if it
isShared it is cloned before returning to prevent corruption of
the query cache. |
DatabaseQuery |
getDatabaseQueryInternal()
INTERNAL: Return the cached database query for this EJBQueryImpl.
|
protected java.lang.RuntimeException |
getDetailedException(DatabaseException e)
Given a DatabaseException, this method will determine if we should
throw a different more specific exception like a lock timeout exception.
|
JpaEntityManager |
getEntityManager()
Return the entityManager this query is tied to.
|
int |
getFirstResult() |
FlushModeType |
getFlushMode() |
java.util.Map<java.lang.String,java.lang.Object> |
getHints() |
protected java.util.Map<java.lang.String,<any>> |
getInternalParameters()
Return the internal map of parameters.
|
LockModeType |
getLockMode()
Get the current lock mode for the query.
|
int |
getMaxResults() |
int |
getMaxResultsInternal() |
<any> |
getParameter(int position) |
<T> <any> |
getParameter(int position,
java.lang.Class<T> type) |
<any> |
getParameter(java.lang.String name) |
<T> <any> |
getParameter(java.lang.String name,
java.lang.Class<T> type) |
static java.lang.String |
getParameterId(Parameter param)
Return the identifier of this parameter.
|
java.util.Set<<any>> |
getParameters() |
<T> T |
getParameterValue(<any> param) |
java.lang.Object |
getParameterValue(int position)
Return the value bound to the positional parameter.
|
java.lang.Object |
getParameterValue(java.lang.String name)
Return the value bound to the named parameter.
|
java.util.List |
getResultList()
Execute the query and return the query results as a List.
|
java.lang.Object |
getSingleResult()
Execute a SELECT query that returns a single untyped result.
|
java.util.Set<java.lang.String> |
getSupportedHints() |
boolean |
isBound(<any> param)
Return a boolean indicating whether a value has been bound to the
parameter.
|
protected boolean |
isFlushModeAUTO()
Spec.
|
protected boolean |
isValidActualParameter(java.lang.Object value,
java.lang.Class parameterType) |
protected void |
performPreQueryFlush() |
protected java.util.List<java.lang.Object> |
processParameters()
Internal method to add the parameters values to the query prior to
execution.
|
protected void |
propagateResultProperties()
Configure the firstResult, maxRows and lock mode in the EclipseLink
ReadQuery.
|
protected void |
setAsDataModifyQuery()
INTERNAL:
Change the internal query to data modify query.
|
protected void |
setAsSQLModifyQuery()
Internal method to change the wrapped query to a DataModifyQuery if
necessary.
|
protected void |
setAsSQLReadQuery()
Internal method to change the wrapped query to a DataReadQuery if
necessary.
|
void |
setDatabaseQuery(DatabaseQuery query)
Replace the cached query with the given query.
|
QueryImpl |
setFirstResult(int startPosition)
Set the position of the first result to retrieve.
|
protected void |
setFirstResultInternal(int startPosition)
Set the position of the first result to retrieve.
|
QueryImpl |
setFlushMode(FlushModeType flushMode)
Set the flush mode type to be used for the query execution.
|
protected void |
setHintInternal(java.lang.String hintName,
java.lang.Object value)
Set an implementation-specific hint.
|
QueryImpl |
setLockMode(LockModeType lockMode)
Set the lock mode type to be used for the query execution.
|
QueryImpl |
setMaxResults(int maxResult)
Set the maximum number of results to retrieve.
|
void |
setMaxResultsInternal(int maxResult)
Set the maximum number of results to retrieve.
|
protected void |
setParameterInternal(int position,
java.lang.Object value)
Bind an argument to a positional parameter.
|
protected void |
setParameterInternal(java.lang.String name,
java.lang.Object value,
boolean isIndex)
Bind an argument to a named or indexed parameter.
|
protected void |
setRollbackOnly() |
protected void |
throwNonUniqueResultException(java.lang.String message) |
protected void |
throwNoResultException(java.lang.String message) |
java.lang.String |
toString() |
<T> T |
unwrap(java.lang.Class<T> cls)
Unwrap the query into the JPA implementation classes/interfaces or the
underlying native EclipseLink query.
|
public static final int UNDEFINED
protected DatabaseQuery databaseQuery
isSharedprotected EntityManagerImpl entityManager
protected java.lang.String queryName
protected java.util.Map<java.lang.String,java.lang.Object> parameterValues
protected java.util.Map<java.lang.String,<any>> parameters
protected int firstResultIndex
protected int maxResults
protected LockModeType lockMode
protected boolean isShared
protected QueryImpl(EntityManagerImpl entityManager)
public QueryImpl(DatabaseQuery query,
EntityManagerImpl entityManager)
public void close()
protected void setAsDataModifyQuery()
protected void setAsSQLModifyQuery()
protected void setAsSQLReadQuery()
protected java.lang.Object executeReadQuery()
public int executeUpdate()
public DatabaseQuery getDatabaseQuery()
DatabaseQuery ensuring that if it
isShared it is cloned before returning to prevent corruption of
the query cache.getDatabaseQueryInternal()public DatabaseQuery getDatabaseQueryInternal()
protected java.lang.RuntimeException getDetailedException(DatabaseException e)
public JpaEntityManager getEntityManager()
protected java.util.Map<java.lang.String,<any>> getInternalParameters()
public LockModeType getLockMode()
java.lang.IllegalStateException - if not a Java Persistence query language SELECT querypublic java.util.List getResultList()
public java.lang.Object getSingleResult()
NoResultException - if there is no resultNonUniqueResultException - if more than one resultjava.lang.IllegalStateException - if called for a Java Persistence query
language UPDATE or DELETE statementQueryTimeoutException - if the query execution exceeds the query
timeout value set and only the statement is rolled backTransactionRequiredException - if a lock mode other than NONE has
been been set and there is no transaction or the persistence
context has not been joined to the transactionPessimisticLockException - if pessimistic locking fails and the
transaction is rolled backLockTimeoutException - if pessimistic locking fails and only the
statement is rolled backPersistenceException - if the query execution exceeds the query
timeout value set and the transaction is rolled backprotected java.util.List<java.lang.Object> processParameters()
public void setDatabaseQuery(DatabaseQuery query)
public QueryImpl setFirstResult(int startPosition)
startPosition - position of the first result, numbered from 0public int getFirstResult()
javax.persistence.Query#getFirstResult()public QueryImpl setFlushMode(FlushModeType flushMode)
flushMode - protected void setFirstResultInternal(int startPosition)
startPosition - position of the first result, numbered from 0.protected static void applyArguments(StoredProcedureCall call,
DatabaseQuery query)
protected static DatabaseQuery applyHints(java.util.Map<java.lang.String,java.lang.Object> hints,
DatabaseQuery query,
java.lang.ClassLoader classLoader,
AbstractSession session)
hints - a list of hints to be applied to the queryquery - the query to apply the hints topublic static java.lang.String getParameterId(Parameter param)
param - public boolean isBound(<any> param)
param - parameter objectprotected boolean isFlushModeAUTO()
protected void setHintInternal(java.lang.String hintName,
java.lang.Object value)
java.lang.IllegalArgumentException - if the second argument is not valid for the implementation.public QueryImpl setLockMode(LockModeType lockMode)
lockMode - java.lang.IllegalStateException - if not a Java Persistence query language SELECT queryprotected void cloneSharedQuery()
protected java.lang.Object convertTemporalType(java.lang.Object value,
TemporalType type)
public QueryImpl setMaxResults(int maxResult)
maxResult - public int getMaxResults()
javax.persistence.Query#getMaxResults()public int getMaxResultsInternal()
javax.persistence.Query#getMaxResults()public void setMaxResultsInternal(int maxResult)
maxResult - protected void propagateResultProperties()
protected void setParameterInternal(int position,
java.lang.Object value)
position - value - protected void setParameterInternal(java.lang.String name,
java.lang.Object value,
boolean isIndex)
name - the parameter namevalue - to bindisIndex - defines if index or namedprotected boolean isValidActualParameter(java.lang.Object value,
java.lang.Class parameterType)
protected Session getActiveSession()
protected void performPreQueryFlush()
protected void setRollbackOnly()
protected void throwNoResultException(java.lang.String message)
protected void throwNonUniqueResultException(java.lang.String message)
public FlushModeType getFlushMode()
Query#getFlushMode()public java.util.Map<java.lang.String,java.lang.Object> getHints()
Query#getHints()public <T> <any> getParameter(java.lang.String name,
java.lang.Class<T> type)
Query#getParameter(String, Class)public <T> <any> getParameter(int position,
java.lang.Class<T> type)
Query#getParameter(int, Class)public <any> getParameter(java.lang.String name)
Query#getParameter(String, Class)public <any> getParameter(int position)
Query#getParameter(int, Class)public <T> T getParameterValue(<any> param)
Query#getParameterValue(Parameter)public java.lang.Object getParameterValue(java.lang.String name)
name - java.lang.IllegalStateException - if the parameter has not been been boundpublic java.lang.Object getParameterValue(int position)
position - java.lang.IllegalStateException - if the parameter has not been been boundpublic java.util.Set<<any>> getParameters()
Query#getParameters()public java.util.Set<java.lang.String> getSupportedHints()
public <T> T unwrap(java.lang.Class<T> cls)
Query#unwrap(Class)public java.lang.String toString()
toString in class java.lang.Object