Package org.hibernate.hql.ast
Class QueryTranslatorImpl
java.lang.Object
org.hibernate.hql.ast.QueryTranslatorImpl
- All Implemented Interfaces:
FilterTranslator,QueryTranslator
A QueryTranslator that uses an Antlr-based parser.
-
Nested Class Summary
Nested Classes -
Field Summary
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
ConstructorsConstructorDescriptionQueryTranslatorImpl(String queryIdentifier, String query, Map enabledFilters, SessionFactoryImplementor factory) Creates a new AST-based query translator. -
Method Summary
Modifier and TypeMethodDescriptionvoidCompile a filter.voidCompile a "normal" query.booleanDoes the translated query contain collection fetches?intexecuteUpdate(QueryParameters queryParameters, SessionImplementor session) Perform a bulk update/delete operation given the underlying query definition.String[][]Returns the column names in the generated SQL.Returns the filters enabled for this query translator.int[]getNamedParameterLocs(String name) Return information about any parameters encountered during translation.Retrieve the query identifier for this translator.Returns the set of query spaces (table names) that the query refers to.Returns the HQL string processed by the translator.String[]Returns an array of HQL aliasesType[]Types of the return values of an iterate() style query.The SQL query string to be called; implemented by all subclassesbooleanbooleaniterate(QueryParameters queryParameters, EventSource session) Return the query results as an iteratorlist(SessionImplementor session, QueryParameters queryParameters) Perform a list operation given the underlying query definition.scroll(QueryParameters queryParameters, SessionImplementor session) Return the query results, as an instance of ScrollableResultsvoidValidate the scrollability of the translated query.
-
Constructor Details
-
QueryTranslatorImpl
public QueryTranslatorImpl(String queryIdentifier, String query, Map enabledFilters, SessionFactoryImplementor factory) Creates a new AST-based query translator.- Parameters:
queryIdentifier- The query-identifier (used in stats collection)query- The hql query to translateenabledFilters- Currently enabled filtersfactory- The session factory constructing this translator instance.
-
-
Method Details
-
compile
Compile a "normal" query. This method may be called multiple times. Subsequent invocations are no-ops.- Specified by:
compilein interfaceQueryTranslator- Parameters:
replacements- Defined query substitutions.shallow- Does this represent a shallow (scalar or entity-id) select?- Throws:
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 shallow) throws QueryException, MappingException Compile a filter. This method may be called multiple times. Subsequent invocations are no-ops.- Specified by:
compilein interfaceFilterTranslator- Parameters:
collectionRole- the role name of the collection used as the basis for the filter.replacements- Defined query substitutions.shallow- Does this represent a shallow (scalar or entity-id) select?- Throws:
QueryException- There was a problem parsing the query string.MappingException- There was a problem querying defined mappings.
-
getQueryIdentifier
Description copied from interface:QueryTranslatorRetrieve the query identifier for this translator. The query identifier is used in states collection.- Specified by:
getQueryIdentifierin interfaceQueryTranslator- Returns:
- the identifier
-
getSqlAST
-
getReturnTypes
Types of the return values of an iterate() style query.- Specified by:
getReturnTypesin interfaceQueryTranslator- Returns:
- an array of Types.
-
getReturnAliases
Description copied from interface:QueryTranslatorReturns an array of HQL aliases- Specified by:
getReturnAliasesin interfaceQueryTranslator
-
getColumnNames
Description copied from interface:QueryTranslatorReturns the column names in the generated SQL.- Specified by:
getColumnNamesin interfaceQueryTranslator- Returns:
- the column names in the generated SQL.
-
getQuerySpaces
Description copied from interface:QueryTranslatorReturns the set of query spaces (table names) that the query refers to.- Specified by:
getQuerySpacesin interfaceQueryTranslator- Returns:
- A set of query spaces (table names).
-
list
public List list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException Description copied from interface:QueryTranslatorPerform a list operation given the underlying query definition.- Specified by:
listin interfaceQueryTranslator- Parameters:
session- The session owning this query.queryParameters- The query bind parameters.- Returns:
- The query list results.
- Throws:
HibernateException
-
iterate
public Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException Return the query results as an iterator- Specified by:
iteratein interfaceQueryTranslator- Parameters:
queryParameters- The query bind parameters.session- The session owning this query.- Returns:
- An iterator over the query results.
- Throws:
HibernateException
-
scroll
public ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session) throws HibernateException Return the query results, as an instance of ScrollableResults- Specified by:
scrollin interfaceQueryTranslator- Parameters:
queryParameters- The query bind parameters.session- The session owning this query.- Returns:
- The ScrollableResults wrapper around the query results.
- Throws:
HibernateException
-
executeUpdate
public int executeUpdate(QueryParameters queryParameters, SessionImplementor session) throws HibernateException Description copied from interface:QueryTranslatorPerform a bulk update/delete operation given the underlying query definition.- Specified by:
executeUpdatein interfaceQueryTranslator- Parameters:
queryParameters- The query bind parameters.session- The session owning this query.- Returns:
- The number of entities updated or deleted.
- Throws:
HibernateException
-
getSQLString
The SQL query string to be called; implemented by all subclasses- Specified by:
getSQLStringin interfaceQueryTranslator- Returns:
- the SQL string generated by the translator.
-
collectSqlStrings
- Specified by:
collectSqlStringsin interfaceQueryTranslator
-
isShallowQuery
public boolean isShallowQuery() -
getQueryString
Description copied from interface:QueryTranslatorReturns the HQL string processed by the translator.- Specified by:
getQueryStringin interfaceQueryTranslator- Returns:
- the HQL string processed by the translator.
-
getEnabledFilters
Description copied from interface:QueryTranslatorReturns the filters enabled for this query translator.- Specified by:
getEnabledFiltersin interfaceQueryTranslator- Returns:
- Filters enabled for this query execution.
-
getNamedParameterLocs
-
containsCollectionFetches
public boolean containsCollectionFetches()Description copied from interface:QueryTranslatorDoes the translated query contain collection fetches?- Specified by:
containsCollectionFetchesin interfaceQueryTranslator- Returns:
- true if the query does contain collection fetched; false otherwise.
-
isManipulationStatement
public boolean isManipulationStatement()- Specified by:
isManipulationStatementin interfaceQueryTranslator
-
validateScrollability
Description copied from interface:QueryTranslatorValidate the scrollability of the translated query.- Specified by:
validateScrollabilityin interfaceQueryTranslator- Throws:
HibernateException
-
getParameterTranslations
Description copied from interface:QueryTranslatorReturn information about any parameters encountered during translation.- Specified by:
getParameterTranslationsin interfaceQueryTranslator- Returns:
- The parameter information.
-
getCollectedParameterSpecifications
-
getDynamicInstantiationResultType
- Specified by:
getDynamicInstantiationResultTypein interfaceQueryTranslator
-