public abstract class AbstractQueryImpl extends Object implements Query
| Modifier and Type | Field and Description |
|---|---|
protected ParameterMetadata |
parameterMetadata |
protected SessionImplementor |
session |
| Constructor and Description |
|---|
AbstractQueryImpl(String queryString,
FlushMode flushMode,
SessionImplementor session,
ParameterMetadata parameterMetadata) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
after() |
protected void |
before() |
protected Type |
determineType(int paramPosition,
Object paramValue) |
protected Type |
determineType(int paramPosition,
Object paramValue,
Type defaultType) |
protected Type |
determineType(String paramName,
Class clazz) |
protected Type |
determineType(String paramName,
Object paramValue) |
protected Type |
determineType(String paramName,
Object paramValue,
Type defaultType) |
protected String |
expandParameterLists(Map namedParamsCopy)
Warning: adds new parameters to the argument by side-effect, as well as
mutating the query string!
|
CacheMode |
getCacheMode() |
abstract LockOptions |
getLockOptions() |
protected Map |
getNamedParameterLists()
Retreive the value map for any named parameter lists (i.e., for
auto-expansion) bound to this query.
|
String[] |
getNamedParameters()
Returns an array representing all named parameter names encountered
during (intial) parsing of the query.
|
protected Map |
getNamedParams()
Returns a shallow copy of the named parameter value map.
|
ParameterMetadata |
getParameterMetadata() |
QueryParameters |
getQueryParameters(Map namedParams) |
String |
getQueryString()
Get the query string.
|
String[] |
getReturnAliases()
Return the HQL select clause aliases (if any)
|
Type[] |
getReturnTypes()
Return the Hibernate types of the query result set.
|
protected RowSelection |
getRowSelection() |
RowSelection |
getSelection() |
protected List |
getTypes()
Retreives the list of parameter
types bound to this query for
ordinal parameters. |
protected List |
getValues()
Retreives the list of parameter values bound to this query for
ordinal parameters.
|
boolean |
hasNamedParameters()
Does this query contain named parameters?
|
boolean |
isReadOnly()
Should entities and proxies loaded by this Query be put in read-only mode? If the
read-only/modifiable setting was not initialized, then the default
read-only/modifiable setting for the persistence context is returned instead.
|
Query |
setBigDecimal(int position,
BigDecimal number) |
Query |
setBigDecimal(String name,
BigDecimal number) |
Query |
setBigInteger(int position,
BigInteger number) |
Query |
setBigInteger(String name,
BigInteger number) |
Query |
setBinary(int position,
byte[] val) |
Query |
setBinary(String name,
byte[] val) |
Query |
setBoolean(int position,
boolean val) |
Query |
setBoolean(String name,
boolean val) |
Query |
setByte(int position,
byte val) |
Query |
setByte(String name,
byte val) |
Query |
setCacheable(boolean cacheable)
Enable caching of this query result set.
|
Query |
setCacheMode(CacheMode cacheMode)
Override the current session cache mode, just for
this query.
|
Query |
setCacheRegion(String cacheRegion)
Set the name of the cache region.
|
Query |
setCalendar(int position,
Calendar calendar) |
Query |
setCalendar(String name,
Calendar calendar) |
Query |
setCalendarDate(int position,
Calendar calendar) |
Query |
setCalendarDate(String name,
Calendar calendar) |
Query |
setCharacter(int position,
char val) |
Query |
setCharacter(String name,
char val) |
Query |
setCollectionKey(Serializable collectionKey) |
Query |
setComment(String comment)
Add a comment to the generated SQL.
|
Query |
setDate(int position,
Date date) |
Query |
setDate(String name,
Date date)
Bind the date (time is truncated) of a given Date object to a named query parameter.
|
Query |
setDouble(int position,
double val) |
Query |
setDouble(String name,
double val) |
Query |
setEntity(int position,
Object val)
Bind an instance of a mapped persistent class to a JDBC-style query parameter.
|
Query |
setEntity(String name,
Object val)
Bind an instance of a mapped persistent class to a named query parameter.
|
Query |
setFetchSize(int fetchSize)
Set a fetch size for the underlying JDBC query.
|
Query |
setFirstResult(int firstResult)
Set the first row to retrieve.
|
Query |
setFloat(int position,
float val) |
Query |
setFloat(String name,
float val) |
Query |
setFlushMode(FlushMode flushMode)
Override the current session flush mode, just for
this query.
|
Query |
setInteger(int position,
int val) |
Query |
setInteger(String name,
int val) |
Query |
setLocale(int position,
Locale locale) |
Query |
setLocale(String name,
Locale locale) |
Query |
setLong(int position,
long val) |
Query |
setLong(String name,
long val) |
Query |
setMaxResults(int maxResults)
Set the maximum number of rows to retrieve.
|
void |
setOptionalEntityName(String optionalEntityName) |
void |
setOptionalId(Serializable optionalId) |
void |
setOptionalObject(Object optionalObject) |
Query |
setParameter(int position,
Object val)
Bind a value to a JDBC-style query parameter.
|
Query |
setParameter(int position,
Object val,
Type type)
Bind a value to a JDBC-style query parameter.
|
Query |
setParameter(String name,
Object val)
Bind a value to a named query parameter.
|
Query |
setParameter(String name,
Object val,
Type type)
Bind a value to a named query parameter.
|
Query |
setParameterList(String name,
Collection vals)
Bind multiple values to a named query parameter.
|
Query |
setParameterList(String name,
Collection vals,
Type type)
Bind multiple values to a named query parameter.
|
Query |
setParameterList(String name,
Object[] vals)
Bind multiple values to a named query parameter.
|
Query |
setParameterList(String name,
Object[] vals,
Type type)
Bind multiple values to a named query parameter.
|
Query |
setParameters(Object[] values,
Type[] types)
Bind values and types to positional parameters.
|
Query |
setProperties(Map map)
Bind the values of the given Map for each named parameters of the query,
matching key names with parameter names and mapping value types to
Hibernate types using hueristics.
|
Query |
setProperties(Object bean)
Bind the property values of the given bean to named parameters of the query,
matching property names with parameter names and mapping property types to
Hibernate types using hueristics.
|
Query |
setReadOnly(boolean readOnly)
Set the read-only/modifiable mode for entities and proxies
loaded by this Query.
|
Query |
setResultTransformer(ResultTransformer transformer)
Set a strategy for handling the query results.
|
Query |
setSerializable(int position,
Serializable val) |
Query |
setSerializable(String name,
Serializable val) |
Query |
setShort(int position,
short val) |
Query |
setShort(String name,
short val) |
Query |
setString(int position,
String val) |
Query |
setString(String name,
String val) |
Query |
setText(int position,
String val) |
Query |
setText(String name,
String val) |
Query |
setTime(int position,
Date date) |
Query |
setTime(String name,
Date date)
Bind the time (date is truncated) of a given Date object to a named query parameter.
|
Query |
setTimeout(int timeout)
Set a timeout for the underlying JDBC query.
|
Query |
setTimestamp(int position,
Date date) |
Query |
setTimestamp(String name,
Date date)
Bind the date and the time of a given Date object to a named query parameter.
|
String |
toString() |
Type[] |
typeArray() |
Object |
uniqueResult()
Convenience method to return a single instance that matches
the query, or null if the query returns no results.
|
Object[] |
valueArray() |
protected void |
verifyParameters()
Perform parameter validation.
|
protected void |
verifyParameters(boolean reserveFirstParameter)
Perform parameter validation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexecuteUpdate, iterate, list, scroll, scroll, setLockMode, setLockOptionsprotected final SessionImplementor session
protected final ParameterMetadata parameterMetadata
public AbstractQueryImpl(String queryString, FlushMode flushMode, SessionImplementor session, ParameterMetadata parameterMetadata)
public ParameterMetadata getParameterMetadata()
public final String getQueryString()
QuerygetQueryString in interface Querypublic RowSelection getSelection()
public Query setFlushMode(FlushMode flushMode)
QuerysetFlushMode in interface QueryFlushModepublic Query setCacheMode(CacheMode cacheMode)
QuerysetCacheMode in interface QueryCacheModepublic CacheMode getCacheMode()
public Query setCacheable(boolean cacheable)
QuerysetCacheable in interface Querycacheable - Should the query results be cacheable?public Query setCacheRegion(String cacheRegion)
QuerysetCacheRegion in interface QuerycacheRegion - the name of a query cache region, or null
for the default query cachepublic Query setComment(String comment)
QuerysetComment in interface Querycomment - a human-readable stringpublic Query setFirstResult(int firstResult)
QuerysetFirstResult in interface QueryfirstResult - a row number, numbered from 0public Query setMaxResults(int maxResults)
QuerysetMaxResults in interface QuerymaxResults - the maximum number of rowspublic Query setTimeout(int timeout)
QuerysetTimeout in interface Querytimeout - the timeout in secondspublic Query setFetchSize(int fetchSize)
QuerysetFetchSize in interface QueryfetchSize - the fetch sizepublic Type[] getReturnTypes() throws HibernateException
QuerygetReturnTypes in interface QueryHibernateExceptionpublic String[] getReturnAliases() throws HibernateException
QuerygetReturnAliases in interface QueryHibernateExceptionpublic Query setCollectionKey(Serializable collectionKey)
public boolean isReadOnly()
isReadOnly in interface QueryQuery.setReadOnly(boolean),
The read-only/modifiable setting has no impact on entities/proxies returned by the
query that existed in the session before the query was executed.public Query setReadOnly(boolean readOnly)
setReadOnly in interface QueryreadOnly - true, entities and proxies loaded by the query will be put in read-only mode
false, entities and proxies loaded by the query will be put in modifiable modeTo set the default read-only/modifiable setting used for
entities and proxies that are loaded into the session:,
PersistenceContext.setDefaultReadOnly(boolean),
Read-only entities are not dirty-checked and snapshots of persistent
state are not maintained. Read-only entities can be modified, but
changes are not persisted.
When a proxy is initialized, the loaded entity will have the same
read-only/modifiable setting as the uninitialized
proxy has, regardless of the session's current setting.
The read-only/modifiable setting has no impact on entities/proxies
returned by the query that existed in the session before the query was executed.public Query setResultTransformer(ResultTransformer transformer)
QuerysetResultTransformer in interface Querytransformer - The transformer to applypublic void setOptionalEntityName(String optionalEntityName)
public void setOptionalId(Serializable optionalId)
public void setOptionalObject(Object optionalObject)
public abstract LockOptions getLockOptions()
protected Map getNamedParams()
public String[] getNamedParameters() throws HibernateException
getNamedParameters in interface QueryHibernateExceptionpublic boolean hasNamedParameters()
protected Map getNamedParameterLists()
protected List getValues()
protected List getTypes()
types bound to this query for
ordinal parameters.protected void verifyParameters()
throws QueryException
QueryExceptionprotected void verifyParameters(boolean reserveFirstParameter)
throws HibernateException
reserveFirstParameter - if true, the first ? will not be verified since
its needed for e.g. callable statements returning a out parameterHibernateExceptionpublic Query setParameter(int position, Object val, Type type)
QuerysetParameter in interface Queryposition - the position of the parameter in the query
string, numbered from 0.val - the possibly-null parameter valuetype - the Hibernate typepublic Query setParameter(String name, Object val, Type type)
QuerysetParameter in interface Queryname - the name of the parameterval - the possibly-null parameter valuetype - the Hibernate typepublic Query setParameter(int position, Object val) throws HibernateException
QuerysetParameter in interface Queryposition - the position of the parameter in the query
string, numbered from 0.val - the non-null parameter valueHibernateException - if no type could be determinedpublic Query setParameter(String name, Object val) throws HibernateException
QuerysetParameter in interface Queryname - the name of the parameterval - the non-null parameter valueHibernateException - if no type could be determinedprotected Type determineType(int paramPosition, Object paramValue) throws HibernateException
HibernateExceptionprotected Type determineType(String paramName, Object paramValue) throws HibernateException
HibernateExceptionprotected Type determineType(String paramName, Class clazz) throws HibernateException
HibernateExceptionpublic Query setCharacter(int position, char val)
setCharacter in interface Querypublic Query setBoolean(int position, boolean val)
setBoolean in interface Querypublic Query setInteger(int position, int val)
setInteger in interface Querypublic Query setDouble(int position, double val)
public Query setBinary(int position, byte[] val)
public Query setSerializable(int position, Serializable val)
setSerializable in interface Querypublic Query setTimestamp(int position, Date date)
setTimestamp in interface Querypublic Query setEntity(int position, Object val)
Querypublic Query setCalendar(int position, Calendar calendar)
setCalendar in interface Querypublic Query setCalendarDate(int position, Calendar calendar)
setCalendarDate in interface Querypublic Query setBoolean(String name, boolean val)
setBoolean in interface Querypublic Query setCharacter(String name, char val)
setCharacter in interface Querypublic Query setDate(String name, Date date)
Querypublic Query setEntity(String name, Object val)
Querypublic Query setInteger(String name, int val)
setInteger in interface Querypublic Query setCalendar(String name, Calendar calendar)
setCalendar in interface Querypublic Query setCalendarDate(String name, Calendar calendar)
setCalendarDate in interface Querypublic Query setSerializable(String name, Serializable val)
setSerializable in interface Querypublic Query setTime(String name, Date date)
Querypublic Query setTimestamp(String name, Date date)
QuerysetTimestamp in interface Queryname - The name of the parameterdate - The date objectpublic Query setBigDecimal(int position, BigDecimal number)
setBigDecimal in interface Querypublic Query setBigDecimal(String name, BigDecimal number)
setBigDecimal in interface Querypublic Query setBigInteger(int position, BigInteger number)
setBigInteger in interface Querypublic Query setBigInteger(String name, BigInteger number)
setBigInteger in interface Querypublic Query setParameterList(String name, Collection vals, Type type) throws HibernateException
QuerysetParameterList in interface Queryname - the name of the parametervals - a collection of values to listtype - the Hibernate type of the valuesHibernateExceptionprotected String expandParameterLists(Map namedParamsCopy)
public Query setParameterList(String name, Collection vals) throws HibernateException
QuerysetParameterList in interface Queryname - the name of the parametervals - a collection of values to listHibernateExceptionpublic Query setParameterList(String name, Object[] vals, Type type) throws HibernateException
QuerysetParameterList in interface Queryname - the name of the parametervals - a collection of values to listtype - the Hibernate type of the valuesHibernateExceptionpublic Query setParameterList(String name, Object[] vals) throws HibernateException
QuerysetParameterList in interface Queryname - the name of the parametervals - a collection of values to listHibernateExceptionpublic Query setProperties(Map map) throws HibernateException
QuerysetProperties in interface Querymap - a java.util.MapHibernateExceptionpublic Query setProperties(Object bean) throws HibernateException
QuerysetProperties in interface Querybean - any JavaBean or POJOHibernateExceptionpublic Query setParameters(Object[] values, Type[] types)
QuerysetParameters in interface Querypublic Object uniqueResult() throws HibernateException
QueryuniqueResult in interface QueryNonUniqueResultException - if there is more than one matching resultHibernateExceptionprotected RowSelection getRowSelection()
public Type[] typeArray()
public Object[] valueArray()
public QueryParameters getQueryParameters(Map namedParams)
protected void before()
protected void after()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.