|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hibernate.loader.Loader org.hibernate.loader.BasicLoader org.hibernate.hql.classic.QueryTranslatorImpl
public class QueryTranslatorImpl
An instance of QueryTranslator translates a Hibernate query string to SQL.
Field Summary |
---|
Fields inherited from class org.hibernate.loader.BasicLoader |
---|
NO_SUFFIX |
Fields inherited from interface org.hibernate.hql.QueryTranslator |
---|
ERROR_CANNOT_DETERMINE_TYPE, ERROR_CANNOT_FETCH_WITH_ITERATE, ERROR_CANNOT_FORMAT_LITERAL, ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR |
Constructor Summary | |
---|---|
QueryTranslatorImpl(String queryString,
Map enabledFilters,
SessionFactoryImplementor factory)
Construct a query translator; this form used internally. |
|
QueryTranslatorImpl(String queryIdentifier,
String queryString,
Map enabledFilters,
SessionFactoryImplementor factory)
Construct a query translator |
Method Summary | |
---|---|
protected String |
applyLocks(String sql,
LockOptions lockOptions,
Dialect dialect)
Append FOR UPDATE OF clause, if necessary. |
List |
collectSqlStrings()
|
void |
compile(Map replacements,
boolean scalar)
Compile a "normal" query. |
void |
compile(String collectionRole,
Map replacements,
boolean scalar)
Compile a filter. |
boolean |
containsCollectionFetches()
Does the translated query contain collection fetches? |
int |
executeUpdate(QueryParameters queryParameters,
SessionImplementor session)
Perform a bulk update/delete operation given the underlying query definition. |
protected String[] |
getAliases()
Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading |
String |
getAliasName(String alias)
|
protected int[] |
getCollectionOwners()
Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie. |
CollectionPersister[] |
getCollectionPersisters()
Overrides method from Loader |
protected String[] |
getCollectionSuffixes()
|
String[][] |
getColumnNames()
Returns the column names in the generated SQL. |
Class |
getDynamicInstantiationResultType()
|
Map |
getEnabledFilters()
Returns the filters enabled for this query translator. |
protected Loadable[] |
getEntityPersisters()
Persisters for the return values of a find() style query. |
Class |
getHolderClass()
|
protected LockMode[] |
getLockModes(LockOptions lockOptions)
What lock options does this load entities with? |
int[] |
getNamedParameterLocs(String name)
|
protected EntityType[] |
getOwnerAssociationTypes()
An array of the owner types corresponding to the Loader.getOwners()
returns. |
protected int[] |
getOwners()
An array of indexes of the entity that owns a one-to-one association to the entity at the given index (-1 if there is no "owner"). |
ParameterTranslations |
getParameterTranslations()
Return information about any parameters encountered during translation. |
String |
getQueryIdentifier()
Identifies the query for statistics reporting, if null, no statistics will be reported |
Set |
getQuerySpaces()
Returns the set of query spaces (table names) that the query refers to. |
String |
getQueryString()
Returns the HQL string processed by the translator. |
protected Object |
getResultColumnOrRow(Object[] row,
ResultTransformer transformer,
ResultSet rs,
SessionImplementor session)
Get the actual object that is returned in the user-visible result list. |
protected List |
getResultList(List results,
ResultTransformer resultTransformer)
|
String[] |
getReturnAliases()
Returns an array of HQL aliases |
Type[] |
getReturnTypes()
Types of the return values of an iterate() style query. |
String |
getSQLString()
The SQL query string to be called; implemented by all subclasses |
protected String[] |
getSuffixes()
|
protected boolean |
isCompiled()
|
boolean |
isManipulationStatement()
|
protected boolean |
isSubselectLoadingEnabled()
|
Iterator |
iterate(QueryParameters queryParameters,
EventSource session)
Return the query results as an iterator |
List |
list(SessionImplementor session,
QueryParameters queryParameters)
Perform a list operation given the underlying query definition. |
protected ResultTransformer |
resolveResultTransformer(ResultTransformer resultTransformer)
Determine the actual ResultTransformer that will be used to transform query results. |
ScrollableResults |
scroll(QueryParameters queryParameters,
SessionImplementor session)
Perform a scroll operation given the underlying query definition. |
String |
toString()
|
protected boolean |
upgradeLocks()
Does this query return objects that might be already cached by the session, whose lock mode may need upgrading |
void |
validateScrollability()
Validate the scrollability of the translated query. |
Methods inherited from class org.hibernate.loader.BasicLoader |
---|
generateSuffixes, generateSuffixes, getCollectionAliases, getEntityAliases, postInstantiate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public QueryTranslatorImpl(String queryIdentifier, String queryString, Map enabledFilters, SessionFactoryImplementor factory)
queryIdentifier
- A unique identifier for the query of which this
translation is part; typically this is the original, user-supplied query string.queryString
- The "preprocessed" query string; at the very least
already processed by QuerySplitter
.enabledFilters
- Any enabled filters.factory
- The session factory.public QueryTranslatorImpl(String queryString, Map enabledFilters, SessionFactoryImplementor factory)
queryString
- The query string to process.enabledFilters
- Any enabled filters.factory
- The session factory.Method Detail |
---|
public void compile(Map replacements, boolean scalar) throws QueryException, MappingException
compile
in interface QueryTranslator
replacements
- Defined query substitutions.scalar
- Does this represent a shallow (scalar or entity-id) select?
QueryException
- There was a problem parsing the query string.
MappingException
- There was a problem querying defined mappings.public void compile(String collectionRole, Map replacements, boolean scalar) throws QueryException, MappingException
compile
in interface FilterTranslator
collectionRole
- the role name of the collection used as the basis for the filter.replacements
- Defined query substitutions.scalar
- Does this represent a shallow (scalar or entity-id) select?
QueryException
- There was a problem parsing the query string.
MappingException
- There was a problem querying defined mappings.public String getSQLString()
Loader
getSQLString
in interface QueryTranslator
getSQLString
in class Loader
ResultSet
.public List collectSqlStrings()
collectSqlStrings
in interface QueryTranslator
public String getQueryString()
QueryTranslator
getQueryString
in interface QueryTranslator
protected Loadable[] getEntityPersisters()
getEntityPersisters
in class Loader
public Type[] getReturnTypes()
getReturnTypes
in interface QueryTranslator
public String[] getReturnAliases()
QueryTranslator
getReturnAliases
in interface QueryTranslator
public String[][] getColumnNames()
QueryTranslator
getColumnNames
in interface QueryTranslator
public String getAliasName(String alias)
public int[] getNamedParameterLocs(String name) throws QueryException
getNamedParameterLocs
in class Loader
QueryException
public final Set getQuerySpaces()
QueryTranslator
getQuerySpaces
in interface QueryTranslator
public CollectionPersister[] getCollectionPersisters()
getCollectionPersisters
in class Loader
protected String[] getCollectionSuffixes()
getCollectionSuffixes
in class BasicLoader
protected String[] getSuffixes()
getSuffixes
in class BasicLoader
protected String[] getAliases()
Loader
getAliases
in class Loader
public List list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException
QueryTranslator
list
in interface QueryTranslator
session
- The session owning this query.queryParameters
- The query bind parameters.
HibernateException
public Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException
iterate
in interface QueryTranslator
queryParameters
- The query bind parameters.session
- The session owning this query.
HibernateException
public int executeUpdate(QueryParameters queryParameters, SessionImplementor session) throws HibernateException
QueryTranslator
executeUpdate
in interface QueryTranslator
queryParameters
- The query bind parameters.session
- The session owning this query.
HibernateException
protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)
Loader
resolveResultTransformer
in class Loader
resultTransformer
- the specified result transformer
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException
Loader
getResultColumnOrRow
in class Loader
SQLException
HibernateException
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException
getResultList
in class Loader
QueryException
protected LockMode[] getLockModes(LockOptions lockOptions)
Loader
getLockModes
in class Loader
lockOptions
- a collection of lock options specified dynamically via the Query interfaceprotected String applyLocks(String sql, LockOptions lockOptions, Dialect dialect) throws QueryException
Loader
applyLocks
in class Loader
QueryException
protected boolean upgradeLocks()
Loader
upgradeLocks
in class Loader
protected int[] getCollectionOwners()
Loader
getCollectionOwners
in class Loader
protected boolean isCompiled()
public String toString()
toString
in class Loader
protected int[] getOwners()
Loader
Loader.getEntityPersisters()
.
getOwners
in class Loader
protected EntityType[] getOwnerAssociationTypes()
Loader
Loader.getOwners()
returns. Indices indicating no owner would be null here.
getOwnerAssociationTypes
in class Loader
public Class getHolderClass()
public Map getEnabledFilters()
QueryTranslator
getEnabledFilters
in interface QueryTranslator
public ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session) throws HibernateException
QueryTranslator
scroll
in interface QueryTranslator
queryParameters
- The query bind parameters.session
- The session owning this query.
HibernateException
public String getQueryIdentifier()
Loader
getQueryIdentifier
in interface QueryTranslator
getQueryIdentifier
in class Loader
protected boolean isSubselectLoadingEnabled()
isSubselectLoadingEnabled
in class Loader
public void validateScrollability() throws HibernateException
QueryTranslator
validateScrollability
in interface QueryTranslator
HibernateException
public boolean containsCollectionFetches()
QueryTranslator
containsCollectionFetches
in interface QueryTranslator
public boolean isManipulationStatement()
isManipulationStatement
in interface QueryTranslator
public Class getDynamicInstantiationResultType()
getDynamicInstantiationResultType
in interface QueryTranslator
public ParameterTranslations getParameterTranslations()
QueryTranslator
getParameterTranslations
in interface QueryTranslator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |