类 QueryTranslatorImpl
- java.lang.Object
-
- org.hibernate.loader.Loader
-
- org.hibernate.loader.BasicLoader
-
- org.hibernate.hql.internal.classic.QueryTranslatorImpl
-
- 所有已实现的接口:
FilterTranslator,QueryTranslator
public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator
An instance of QueryTranslator translates a Hibernate query string to SQL.
-
-
嵌套类概要
-
从类继承的嵌套类/接口 org.hibernate.loader.Loader
Loader.SqlStatementWrapper
-
-
字段概要
-
从类继承的字段 org.hibernate.loader.BasicLoader
NO_SUFFIX
-
从类继承的字段 org.hibernate.loader.Loader
SELECT, SELECT_DISTINCT
-
-
构造器概要
构造器 构造器 说明 QueryTranslatorImpl(String queryIdentifier, String queryString, Map enabledFilters, SessionFactoryImplementor factory)Construct a query translatorQueryTranslatorImpl(String queryString, Map enabledFilters, SessionFactoryImplementor factory)Construct a query translator; this form used internally.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected StringapplyLocks(String sql, QueryParameters parameters, Dialect dialect, List<AfterLoadAction> afterLoadActions)Append FOR UPDATE OF clause, if necessary.protected intbindParameterValues(PreparedStatement statement, QueryParameters queryParameters, int startIndex, SharedSessionContractImplementor session)Bind all parameter values into the prepared statement in preparation for execution.List<String>collectSqlStrings()voidcompile(String collectionRole, Map replacements, boolean scalar)Compile a filter.voidcompile(Map replacements, boolean scalar)Compile a "normal" query.booleancontainsCollectionFetches()Does the translated query contain collection fetches?intexecuteUpdate(QueryParameters queryParameters, SharedSessionContractImplementor 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 loadingStringgetAliasName(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. in the case of a collection initializer) or no collection.CollectionPersister[]getCollectionPersisters()An (optional) persister for a collection to be initialized; only collection loaders return a non-null valueprotected String[]getCollectionSuffixes()String[][]getColumnNames()Returns the column names in the generated SQL.ClassgetDynamicInstantiationResultType()MapgetEnabledFilters()Returns the filters enabled for this query translator.protected Loadable[]getEntityPersisters()Persisters for the return values of a find() style query.ClassgetHolderClass()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 theLoader.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").ParameterTranslationsgetParameterTranslations()Return information about any parameters encountered during translation.List<String>getPrimaryFromClauseTables()StringgetQueryIdentifier()Identifies the query for statistics reporting, if null, no statistics will be reportedSet<Serializable>getQuerySpaces()Returns the set of query spaces (table names) that the query refers to.StringgetQueryString()Returns the HQL string processed by the translator.protected ObjectgetResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SharedSessionContractImplementor session)Get the actual object that is returned in the user-visible result list.protected ListgetResultList(List results, ResultTransformer resultTransformer)protected Object[]getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session)String[]getReturnAliases()Returns an array of HQL aliasesType[]getReturnTypes()Types of the return values of an iterate() style query.StringgetSQLString()The SQL query string to be called; implemented by all subclassesprotected String[]getSuffixes()protected boolean[]includeInResultRow()protected booleanisCompiled()booleanisManipulationStatement()protected booleanisSubselectLoadingEnabled()Iteratoriterate(QueryParameters queryParameters, EventSource session)Return the query results as an iteratorListlist(SharedSessionContractImplementor session, QueryParameters queryParameters)Perform a list operation given the underlying query definition.protected ResultTransformerresolveResultTransformer(ResultTransformer resultTransformer)Determine the actual ResultTransformer that will be used to transform query results.ScrollableResultsImplementorscroll(QueryParameters queryParameters, SharedSessionContractImplementor session)Perform a scroll operation given the underlying query definition.StringtoString()protected booleanupgradeLocks()Does this query return objects that might be already cached by the session, whose lock mode may need upgradingvoidvalidateScrollability()Validate the scrollability of the translated query.-
从类继承的方法 org.hibernate.loader.BasicLoader
generateSuffixes, generateSuffixes, getCollectionAliases, getEntityAliases, postInstantiate
-
从类继承的方法 org.hibernate.loader.Loader
applyPostLoadLocks, areResultSetRowsTransformedImmediately, autoDiscoverTypes, bindNamedParameters, bindPositionalParameters, checkScrollability, determineFollowOnLockMode, doList, doQueryAndInitializeNonLazyCollections, doQueryAndInitializeNonLazyCollections, executeQueryStatement, executeQueryStatement, extractKeysFromResultSet, getCompositeKeyManyToOneTargetIndices, getEntityEagerPropertyFetches, getFactory, getLimitHandler, getResultRowAliases, getResultSet, getResultSet, hasSubselectLoadableCollections, isSingleRowLoader, list, loadCollection, loadCollectionBatch, loadCollectionSubselect, loadEntity, loadEntity, loadEntityBatch, loadEntityBatch, loadSequentialRowsForward, loadSequentialRowsReverse, loadSingleRow, needsFetchingScroll, prepareQueryStatement, preprocessSQL, processDistinctKeyword, processResultSet, putResultInQueryCache, scroll, shouldUseFollowOnLocking
-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
从接口继承的方法 org.hibernate.hql.spi.QueryTranslator
isUpdateStatement
-
-
-
-
构造器详细资料
-
QueryTranslatorImpl
public QueryTranslatorImpl(String queryIdentifier, String queryString, Map enabledFilters, SessionFactoryImplementor factory)
Construct a query translator- 参数:
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 byQuerySplitter.enabledFilters- Any enabled filters.factory- The session factory.
-
QueryTranslatorImpl
public QueryTranslatorImpl(String queryString, Map enabledFilters, SessionFactoryImplementor factory)
Construct a query translator; this form used internally.- 参数:
queryString- The query string to process.enabledFilters- Any enabled filters.factory- The session factory.
-
-
方法详细资料
-
compile
public void compile(Map replacements, boolean scalar) throws QueryException, MappingException
Compile a "normal" query. This method may be called multiple times. Subsequent invocations are no-ops.- 指定者:
compile在接口中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.
-
compile
public void compile(String collectionRole, Map replacements, boolean scalar) throws QueryException, MappingException
Compile a filter. This method may be called multiple times. Subsequent invocations are no-ops.- 指定者:
compile在接口中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.
-
getSQLString
public String getSQLString()
从类复制的说明:LoaderThe SQL query string to be called; implemented by all subclasses- 指定者:
getSQLString在接口中QueryTranslator- 指定者:
getSQLString在类中Loader- 返回:
- The sql command this loader should use to get its
ResultSet.
-
collectSqlStrings
public List<String> collectSqlStrings()
- 指定者:
collectSqlStrings在接口中QueryTranslator
-
getQueryString
public String getQueryString()
从接口复制的说明:QueryTranslatorReturns the HQL string processed by the translator.- 指定者:
getQueryString在接口中QueryTranslator- 返回:
- the HQL string processed by the translator.
-
getEntityPersisters
protected Loadable[] getEntityPersisters()
Persisters for the return values of a find() style query.- 指定者:
getEntityPersisters在类中Loader- 返回:
- an array of EntityPersisters.
-
getReturnTypes
public Type[] getReturnTypes()
Types of the return values of an iterate() style query.- 指定者:
getReturnTypes在接口中QueryTranslator- 返回:
- an array of Types.
-
getReturnAliases
public String[] getReturnAliases()
从接口复制的说明:QueryTranslatorReturns an array of HQL aliases- 指定者:
getReturnAliases在接口中QueryTranslator
-
getColumnNames
public String[][] getColumnNames()
从接口复制的说明:QueryTranslatorReturns the column names in the generated SQL.- 指定者:
getColumnNames在接口中QueryTranslator- 返回:
- the column names in the generated SQL.
-
bindParameterValues
protected int bindParameterValues(PreparedStatement statement, QueryParameters queryParameters, int startIndex, SharedSessionContractImplementor session) throws SQLException
从类复制的说明:LoaderBind all parameter values into the prepared statement in preparation for execution.- 覆盖:
bindParameterValues在类中Loader- 参数:
statement- The JDBC prepared statementqueryParameters- The encapsulation of the parameter values to be bound.startIndex- The position from which to start binding parameter values.session- The originating session.- 返回:
- The number of JDBC bind positions actually bound during this method execution.
- 抛出:
SQLException- Indicates problems performing the binding.
-
getNamedParameterLocs
public int[] getNamedParameterLocs(String name) throws QueryException
- 覆盖:
getNamedParameterLocs在类中Loader- 抛出:
QueryException
-
getQuerySpaces
public final Set<Serializable> getQuerySpaces()
从接口复制的说明:QueryTranslatorReturns the set of query spaces (table names) that the query refers to.- 指定者:
getQuerySpaces在接口中QueryTranslator- 返回:
- A set of query spaces (table names).
-
getCollectionPersisters
public CollectionPersister[] getCollectionPersisters()
从类复制的说明:LoaderAn (optional) persister for a collection to be initialized; only collection loaders return a non-null value- 覆盖:
getCollectionPersisters在类中Loader
-
getCollectionSuffixes
protected String[] getCollectionSuffixes()
- 指定者:
getCollectionSuffixes在类中BasicLoader
-
getSuffixes
protected String[] getSuffixes()
- 指定者:
getSuffixes在类中BasicLoader
-
getAliases
protected String[] getAliases()
从类复制的说明:LoaderGet the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading- 覆盖:
getAliases在类中Loader
-
list
public List list(SharedSessionContractImplementor session, QueryParameters queryParameters) throws HibernateException
从接口复制的说明:QueryTranslatorPerform a list operation given the underlying query definition.- 指定者:
list在接口中QueryTranslator- 参数:
session- The session owning this query.queryParameters- The query bind parameters.- 返回:
- The query list results.
- 抛出:
HibernateException
-
iterate
public Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException
Return the query results as an iterator- 指定者:
iterate在接口中QueryTranslator- 参数:
queryParameters- The query bind parameters.session- The session owning this query.- 返回:
- An iterator over the query results.
- 抛出:
HibernateException
-
executeUpdate
public int executeUpdate(QueryParameters queryParameters, SharedSessionContractImplementor session) throws HibernateException
从接口复制的说明:QueryTranslatorPerform a bulk update/delete operation given the underlying query definition.- 指定者:
executeUpdate在接口中QueryTranslator- 参数:
queryParameters- The query bind parameters.session- The session owning this query.- 返回:
- The number of entities updated or deleted.
- 抛出:
HibernateException
-
includeInResultRow
protected boolean[] includeInResultRow()
- 覆盖:
includeInResultRow在类中Loader
-
resolveResultTransformer
protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)
从类复制的说明:LoaderDetermine the actual ResultTransformer that will be used to transform query results.- 覆盖:
resolveResultTransformer在类中Loader- 参数:
resultTransformer- the specified result transformer- 返回:
- the actual result transformer
-
getResultColumnOrRow
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SharedSessionContractImplementor session) throws SQLException, HibernateException
从类复制的说明:LoaderGet the actual object that is returned in the user-visible result list. This empty implementation merely returns its first argument. This is overridden by some subclasses.- 覆盖:
getResultColumnOrRow在类中Loader- 抛出:
SQLExceptionHibernateException
-
getResultRow
protected Object[] getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session) throws SQLException, HibernateException
- 覆盖:
getResultRow在类中Loader- 抛出:
SQLExceptionHibernateException
-
getResultList
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException
- 覆盖:
getResultList在类中Loader- 抛出:
QueryException
-
getLockModes
protected LockMode[] getLockModes(LockOptions lockOptions)
从类复制的说明:LoaderWhat lock options does this load entities with?- 指定者:
getLockModes在类中Loader- 参数:
lockOptions- a collection of lock options specified dynamically via the Query interface
-
applyLocks
protected String applyLocks(String sql, QueryParameters parameters, Dialect dialect, List<AfterLoadAction> afterLoadActions) throws QueryException
从类复制的说明:LoaderAppend FOR UPDATE OF clause, if necessary. This empty superclass implementation merely returns its first argument.- 覆盖:
applyLocks在类中Loader- 抛出:
QueryException
-
upgradeLocks
protected boolean upgradeLocks()
从类复制的说明:LoaderDoes this query return objects that might be already cached by the session, whose lock mode may need upgrading- 覆盖:
upgradeLocks在类中Loader
-
getCollectionOwners
protected int[] getCollectionOwners()
从类复制的说明:LoaderGet the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie. in the case of a collection initializer) or no collection.- 覆盖:
getCollectionOwners在类中Loader
-
isCompiled
protected boolean isCompiled()
-
getOwners
protected int[] getOwners()
从类复制的说明:LoaderAn 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"). The indexes contained here are relative to the result ofLoader.getEntityPersisters().
-
getOwnerAssociationTypes
protected EntityType[] getOwnerAssociationTypes()
从类复制的说明:LoaderAn array of the owner types corresponding to theLoader.getOwners()returns. Indices indicating no owner would be null here.- 覆盖:
getOwnerAssociationTypes在类中Loader- 返回:
- The types for the owners.
-
getHolderClass
public Class getHolderClass()
-
getEnabledFilters
public Map getEnabledFilters()
从接口复制的说明:QueryTranslatorReturns the filters enabled for this query translator.- 指定者:
getEnabledFilters在接口中QueryTranslator- 返回:
- Filters enabled for this query execution.
-
scroll
public ScrollableResultsImplementor scroll(QueryParameters queryParameters, SharedSessionContractImplementor session) throws HibernateException
从接口复制的说明:QueryTranslatorPerform a scroll operation given the underlying query definition.- 指定者:
scroll在接口中QueryTranslator- 参数:
queryParameters- The query bind parameters.session- The session owning this query.- 返回:
- The ScrollableResults wrapper around the query results.
- 抛出:
HibernateException
-
getQueryIdentifier
public String getQueryIdentifier()
从类复制的说明:LoaderIdentifies the query for statistics reporting, if null, no statistics will be reported- 指定者:
getQueryIdentifier在接口中QueryTranslator- 覆盖:
getQueryIdentifier在类中Loader- 返回:
- the identifier
-
isSubselectLoadingEnabled
protected boolean isSubselectLoadingEnabled()
- 覆盖:
isSubselectLoadingEnabled在类中Loader
-
getPrimaryFromClauseTables
public List<String> getPrimaryFromClauseTables()
- 指定者:
getPrimaryFromClauseTables在接口中QueryTranslator
-
validateScrollability
public void validateScrollability() throws HibernateException从接口复制的说明:QueryTranslatorValidate the scrollability of the translated query.- 指定者:
validateScrollability在接口中QueryTranslator- 抛出:
HibernateException
-
containsCollectionFetches
public boolean containsCollectionFetches()
从接口复制的说明:QueryTranslatorDoes the translated query contain collection fetches?- 指定者:
containsCollectionFetches在接口中QueryTranslator- 返回:
- true if the query does contain collection fetched; false otherwise.
-
isManipulationStatement
public boolean isManipulationStatement()
- 指定者:
isManipulationStatement在接口中QueryTranslator
-
getDynamicInstantiationResultType
public Class getDynamicInstantiationResultType()
-
getParameterTranslations
public ParameterTranslations getParameterTranslations()
从接口复制的说明:QueryTranslatorReturn information about any parameters encountered during translation.- 指定者:
getParameterTranslations在接口中QueryTranslator- 返回:
- The parameter information.
-
-