Top Description Inners Fields Constructors Methods
org.hibernate.hql.internal.ast

public Class QueryTranslatorImpl

extends Object
implements FilterTranslator
Class Inheritance
All Implemented Interfaces
org.hibernate.hql.spi.FilterTranslator, org.hibernate.hql.spi.QueryTranslator
Imports
java.io.Serializable, java.util.ArrayList, .Collections, .HashMap, .Iterator, .List, .Map, .Set, java.util.stream.Collectors, .IntStream, org.hibernate.HibernateException, .MappingException, .QueryException, org.hibernate.engine.query.spi.EntityGraphQueryHint, org.hibernate.engine.spi.QueryParameters, .RowSelection, .SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.event.spi.EventSource, org.hibernate.hql.internal.QueryExecutionRequestException, org.hibernate.hql.internal.antlr.HqlSqlTokenTypes, .HqlTokenTypes, .SqlTokenTypes, org.hibernate.hql.internal.ast.exec.DeleteExecutor, .InsertExecutor, .MultiTableDeleteExecutor, .MultiTableUpdateExecutor, .SimpleUpdateExecutor, .StatementExecutor, .IdSubselectUpdateExecutor, org.hibernate.hql.internal.ast.tree.AggregatedSelectExpression, .FromElement, .QueryNode, .Statement, org.hibernate.hql.internal.ast.util.ASTUtil, .NodeTraverser, .TokenPrinters, org.hibernate.hql.spi.FilterTranslator, .ParameterTranslations, org.hibernate.internal.CoreMessageLogger, org.hibernate.internal.util.ReflectHelper, .StringHelper, org.hibernate.internal.util.collections.IdentitySet, org.hibernate.loader.hql.QueryLoader, org.hibernate.param.ParameterSpecification, org.hibernate.persister.entity.Queryable, org.hibernate.query.spi.ScrollableResultsImplementor, org.hibernate.type.Type, org.jboss.logging.Logger, antlr.ANTLRException, .RecognitionException, .TokenStreamException, antlr.collections.AST

A QueryTranslator that uses an Antlr-based parser.
Author
Joshua Davis ([email protected])

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private List<ParameterSpecification>
private boolean
private Map<K, V>
private EntityGraphQueryHint
private SessionFactoryImplementor
factory

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
private String
private static final CoreMessageLogger
private ParameterTranslations
private final String
private QueryLoader
private boolean
private String
private Statement
private StatementExecutor
private Map<K, V>

Constructor Summary

AccessConstructor and Description
public
QueryTranslatorImpl(String
The query-identifier (used in stats collection)
queryIdentifier
,
String
The hql query to translate
query
,
Map<K, V>
Currently enabled filters
enabledFilters
,
SessionFactoryImplementor
The session factory constructing this translator instance.
factory
)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Creates a new AST-based query translator.
public
QueryTranslatorImpl(String queryIdentifier, String query, Map<K, V> enabledFilters, SessionFactoryImplementor factory, EntityGraphQueryHint entityGraphQueryHint)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Method Summary

Modifier and TypeMethod and Description
private static boolean
private HqlSqlWalker
analyze(HqlParser parser, String collectionRole)

protected StatementExecutor
public List<String>
public void
compile(Map<K, V>
Defined query substitutions.
replacements
,
boolean
Does this represent a shallow (scalar or entity-id) select?
shallow
)

Implements org.hibernate.hql.spi.QueryTranslator.compile.

Compile a "normal" query.
public void
compile(String
the role name of the collection used as the basis for the filter.
collectionRole
,
Map<K, V>
Defined query substitutions.
replacements
,
boolean
Does this represent a shallow (scalar or entity-id) select?
shallow
)

Implements org.hibernate.hql.spi.FilterTranslator.compile.

Compile a filter.
public boolean
containsCollectionFetches()

Implements org.hibernate.hql.spi.QueryTranslator.containsCollectionFetches.

Does the translated query contain collection fetches?
protected QueryLoader
createQueryLoader(HqlSqlWalker w, SessionFactoryImplementor factory)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
private synchronized void
doCompile(Map<K, V>
Defined query substitutions.
replacements
,
boolean
Does this represent a shallow (scalar or entity-id) select?
shallow
,
String
the role name of the collection used as the basis for the filter, NULL if this is not a filter.
collectionRole
)

Performs both filter and non-filter compiling.

protected void
private void
public int
executeUpdate(QueryParameters
The query bind parameters.
queryParameters
,
SharedSessionContractImplementor
The session owning this query.
session
)

Implements org.hibernate.hql.spi.QueryTranslator.executeUpdate.

Perform a bulk update/delete operation given the underlying query definition.
private void
generate(AST sqlAst)

public List<ParameterSpecification>
public String[][]
getColumnNames()

Implements org.hibernate.hql.spi.QueryTranslator.getColumnNames.

Returns the column names in the generated SQL.
public Class<T>
public Map<K, V>
getEnabledFilters()

Implements org.hibernate.hql.spi.QueryTranslator.getEnabledFilters.

Returns the filters enabled for this query translator.
public EntityGraphQueryHint
public int[]
public ParameterTranslations
getParameterTranslations()

Implements org.hibernate.hql.spi.QueryTranslator.getParameterTranslations.

Return information about any parameters encountered during translation.
public List<String>
public String
getQueryIdentifier()

Implements org.hibernate.hql.spi.QueryTranslator.getQueryIdentifier.

Retrieve the query identifier for this translator.
public Set<Serializable>
getQuerySpaces()

Implements org.hibernate.hql.spi.QueryTranslator.getQuerySpaces.

Returns the set of query spaces (table names) that the query refers to.
public String
getQueryString()

Implements org.hibernate.hql.spi.QueryTranslator.getQueryString.

Returns the HQL string processed by the translator.
public String[]
getReturnAliases()

Implements org.hibernate.hql.spi.QueryTranslator.getReturnAliases.

Returns an array of HQL aliases
public Type[]

Returns:

an array of Types.
getReturnTypes
()

Implements org.hibernate.hql.spi.QueryTranslator.getReturnTypes.

Types of the return values of an iterate() style query.
public Statement
protected String[]

Returns:

the sql queries used for the update
getSqlStatements
()

The SQl statements used for an update query.

public String
getSQLString()

Implements org.hibernate.hql.spi.QueryTranslator.getSQLString.

The SQL query string to be called; implemented by all subclasses
protected StatementExecutor
private HqlSqlWalker
public boolean
public boolean
public boolean
public Iterator<E>
iterate(QueryParameters
The query bind parameters.
queryParameters
,
EventSource
The session owning this query.
session
)

Implements org.hibernate.hql.spi.QueryTranslator.iterate.

Deprecated as a consequence of EventSource being deprecated.
Return the query results as an iterator
public List<E>
list(SharedSessionContractImplementor
The session owning this query.
session
,
QueryParameters
The query bind parameters.
queryParameters
)

Implements org.hibernate.hql.spi.QueryTranslator.list.

Perform a list operation given the underlying query definition.
private HqlParser
parse(boolean filter)

public ScrollableResultsImplementor
scroll(QueryParameters
The query bind parameters.
queryParameters
,
SharedSessionContractImplementor
The session owning this query.
session
)

Implements org.hibernate.hql.spi.QueryTranslator.scroll.

Return the query results, as an instance of ScrollableResults
public void
pack-priv void
showHqlAst(AST hqlAst)

public void
validateScrollability()

Implements org.hibernate.hql.spi.QueryTranslator.validateScrollability.

Validate the scrollability of the translated query.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

collectedParameterSpecificationsback to summary
private List<ParameterSpecification> collectedParameterSpecifications
compiledback to summary
private boolean compiled
enabledFiltersback to summary
private Map<K, V> enabledFilters
entityGraphQueryHintback to summary
private EntityGraphQueryHint entityGraphQueryHint
factoryback to summary
private SessionFactoryImplementor factory

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

hqlback to summary
private String hql
LOGback to summary
private static final CoreMessageLogger LOG
paramTranslationsback to summary
private ParameterTranslations paramTranslations
queryIdentifierback to summary
private final String queryIdentifier
queryLoaderback to summary
private QueryLoader queryLoader
shallowQueryback to summary
private boolean shallowQuery
sqlback to summary
private String sql
sqlAstback to summary
private Statement sqlAst
statementExecutorback to summary
private StatementExecutor statementExecutor
tokenReplacementsback to summary
private Map<K, V> tokenReplacements

Constructor Detail

QueryTranslatorImplback to summary
public QueryTranslatorImpl(String queryIdentifier, String query, Map<K, V> enabledFilters, SessionFactoryImplementor factory)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Creates a new AST-based query translator.

Parameters
queryIdentifier:String

The query-identifier (used in stats collection)

query:String

The hql query to translate

enabledFilters:Map<K, V>

Currently enabled filters

factory:SessionFactoryImplementor

The session factory constructing this translator instance.

QueryTranslatorImplback to summary
public QueryTranslatorImpl(String queryIdentifier, String query, Map<K, V> enabledFilters, SessionFactoryImplementor factory, EntityGraphQueryHint entityGraphQueryHint)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Method Detail

affectsExtraTablesback to summary
private static boolean affectsExtraTables(HqlSqlWalker walker, Queryable persister)
analyzeback to summary
private HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException
buildAppropriateStatementExecutorback to summary
protected StatementExecutor buildAppropriateStatementExecutor(HqlSqlWalker walker)
collectSqlStringsback to summary
public List<String> collectSqlStrings()

Implements org.hibernate.hql.spi.QueryTranslator.collectSqlStrings.

Annotations
@Override
compileback to summary
public void compile(Map<K, V> replacements, boolean shallow) throws QueryException, MappingException

Implements org.hibernate.hql.spi.QueryTranslator.compile.

Compile a "normal" query. This method may be called multiple times. Subsequent invocations are no-ops.

Parameters
replacements:Map<K, V>

Defined query substitutions.

shallow:boolean

Does this represent a shallow (scalar or entity-id) select?

Annotations
@Override
Exceptions
QueryException:
There was a problem parsing the query string.
MappingException:
There was a problem querying defined mappings.
compileback to summary
public void compile(String collectionRole, Map<K, V> replacements, boolean shallow) throws QueryException, MappingException

Implements org.hibernate.hql.spi.FilterTranslator.compile.

Compile a filter. This method may be called multiple times. Subsequent invocations are no-ops.

Parameters
collectionRole:String

the role name of the collection used as the basis for the filter.

replacements:Map<K, V>

Defined query substitutions.

shallow:boolean

Does this represent a shallow (scalar or entity-id) select?

Annotations
@Override
Exceptions
QueryException:
There was a problem parsing the query string.
MappingException:
There was a problem querying defined mappings.
containsCollectionFetchesback to summary
public boolean containsCollectionFetches()

Implements org.hibernate.hql.spi.QueryTranslator.containsCollectionFetches.

Doc from org.hibernate.hql.spi.QueryTranslator.containsCollectionFetches.

Does the translated query contain collection fetches?

Returns:boolean

true if the query does contain collection fetched; false otherwise.

Annotations
@Override
createQueryLoaderback to summary
protected QueryLoader createQueryLoader(HqlSqlWalker w, SessionFactoryImplementor factory)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

doCompileback to summary
private synchronized void doCompile(Map<K, V> replacements, boolean shallow, String collectionRole)

Performs both filter and non-filter compiling.

Parameters
replacements:Map<K, V>

Defined query substitutions.

shallow:boolean

Does this represent a shallow (scalar or entity-id) select?

collectionRole:String

the role name of the collection used as the basis for the filter, NULL if this is not a filter.

errorIfDMLback to summary
protected void errorIfDML() throws HibernateException
errorIfSelectback to summary
private void errorIfSelect() throws HibernateException
executeUpdateback to summary
public int executeUpdate(QueryParameters queryParameters, SharedSessionContractImplementor session) throws HibernateException

Implements org.hibernate.hql.spi.QueryTranslator.executeUpdate.

Doc from org.hibernate.hql.spi.QueryTranslator.executeUpdate.

Perform a bulk update/delete operation given the underlying query definition.

Parameters
queryParameters:QueryParameters

The query bind parameters.

session:SharedSessionContractImplementor

The session owning this query.

Returns:int

The number of entities updated or deleted.

Annotations
@Override
generateback to summary
private void generate(AST sqlAst) throws QueryException, RecognitionException
getCollectedParameterSpecificationsback to summary
public List<ParameterSpecification> getCollectedParameterSpecifications()
getColumnNamesback to summary
public String[][] getColumnNames()

Implements org.hibernate.hql.spi.QueryTranslator.getColumnNames.

Doc from org.hibernate.hql.spi.QueryTranslator.getColumnNames.

Returns the column names in the generated SQL.

Returns:String[][]

the column names in the generated SQL.

Annotations
@Override
getDynamicInstantiationResultTypeback to summary
public Class<T> getDynamicInstantiationResultType()

Implements org.hibernate.hql.spi.QueryTranslator.getDynamicInstantiationResultType.

Annotations
@Override
getEnabledFiltersback to summary
public Map<K, V> getEnabledFilters()

Implements org.hibernate.hql.spi.QueryTranslator.getEnabledFilters.

Doc from org.hibernate.hql.spi.QueryTranslator.getEnabledFilters.

Returns the filters enabled for this query translator.

Returns:Map<K, V>

Filters enabled for this query execution.

Annotations
@Override
getEntityGraphQueryHintback to summary
public EntityGraphQueryHint getEntityGraphQueryHint()
getNamedParameterLocsback to summary
public int[] getNamedParameterLocs(String name)
getParameterTranslationsback to summary
public ParameterTranslations getParameterTranslations()

Implements org.hibernate.hql.spi.QueryTranslator.getParameterTranslations.

Doc from org.hibernate.hql.spi.QueryTranslator.getParameterTranslations.

Return information about any parameters encountered during translation.

Returns:ParameterTranslations

The parameter information.

Annotations
@Override
getPrimaryFromClauseTablesback to summary
public List<String> getPrimaryFromClauseTables()

Overrides default org.hibernate.hql.spi.QueryTranslator.getPrimaryFromClauseTables.

Annotations
@Override
getQueryIdentifierback to summary
public String getQueryIdentifier()

Implements org.hibernate.hql.spi.QueryTranslator.getQueryIdentifier.

Doc from org.hibernate.hql.spi.QueryTranslator.getQueryIdentifier.

Retrieve the query identifier for this translator. The query identifier is used in states collection.

Returns:String

the identifier

Annotations
@Override
getQuerySpacesback to summary
public Set<Serializable> getQuerySpaces()

Implements org.hibernate.hql.spi.QueryTranslator.getQuerySpaces.

Doc from org.hibernate.hql.spi.QueryTranslator.getQuerySpaces.

Returns the set of query spaces (table names) that the query refers to.

Returns:Set<Serializable>

A set of query spaces (table names).

Annotations
@Override
getQueryStringback to summary
public String getQueryString()

Implements org.hibernate.hql.spi.QueryTranslator.getQueryString.

Doc from org.hibernate.hql.spi.QueryTranslator.getQueryString.

Returns the HQL string processed by the translator.

Returns:String

the HQL string processed by the translator.

Annotations
@Override
getReturnAliasesback to summary
public String[] getReturnAliases()

Implements org.hibernate.hql.spi.QueryTranslator.getReturnAliases.

Doc from org.hibernate.hql.spi.QueryTranslator.getReturnAliases.

Returns an array of HQL aliases

Annotations
@Override
getReturnTypesback to summary
public Type[] getReturnTypes()

Implements org.hibernate.hql.spi.QueryTranslator.getReturnTypes.

Types of the return values of an iterate() style query.

Returns:Type[]

an array of Types.

Annotations
@Override
getSqlASTback to summary
public Statement getSqlAST()
getSqlStatementsback to summary
protected String[] getSqlStatements()

The SQl statements used for an update query. Throws exception if the query is a SELECT.

Returns:String[]

the sql queries used for the update

Exceptions
QueryExecutionRequestException:
for select queries.
See Also
getSQLString()
getSQLStringback to summary
public String getSQLString()

Implements org.hibernate.hql.spi.QueryTranslator.getSQLString.

The SQL query string to be called; implemented by all subclasses

Returns:String

Doc from org.hibernate.hql.spi.QueryTranslator.getSQLString.

the SQL string generated by the translator.

Annotations
@Override
getStatementExecutorback to summary
protected StatementExecutor getStatementExecutor()
getWalkerback to summary
private HqlSqlWalker getWalker()
isManipulationStatementback to summary
public boolean isManipulationStatement()

Implements org.hibernate.hql.spi.QueryTranslator.isManipulationStatement.

Annotations
@Override
isShallowQueryback to summary
public boolean isShallowQuery()
isUpdateStatementback to summary
public boolean isUpdateStatement()

Overrides default org.hibernate.hql.spi.QueryTranslator.isUpdateStatement.

Annotations
@Override
iterateback to summary
public Iterator<E> iterate(QueryParameters queryParameters, EventSource session) throws HibernateException

Implements org.hibernate.hql.spi.QueryTranslator.iterate.

Deprecated

as a consequence of EventSource being deprecated. See corresponding docs for further information.

Return the query results as an iterator

Parameters
queryParameters:QueryParameters

Doc from org.hibernate.hql.spi.QueryTranslator.iterate.

The query bind parameters.

session:EventSource

Doc from org.hibernate.hql.spi.QueryTranslator.iterate.

The session owning this query.

Returns:Iterator<E>

Doc from org.hibernate.hql.spi.QueryTranslator.iterate.

An iterator over the query results.

Annotations
@Override
listback to summary
public List<E> list(SharedSessionContractImplementor session, QueryParameters queryParameters) throws HibernateException

Implements org.hibernate.hql.spi.QueryTranslator.list.

Doc from org.hibernate.hql.spi.QueryTranslator.list.

Perform a list operation given the underlying query definition.

Parameters
session:SharedSessionContractImplementor

The session owning this query.

queryParameters:QueryParameters

The query bind parameters.

Returns:List<E>

The query list results.

Annotations
@Override
parseback to summary
private HqlParser parse(boolean filter) throws TokenStreamException
scrollback to summary
public ScrollableResultsImplementor scroll(QueryParameters queryParameters, SharedSessionContractImplementor session) throws HibernateException

Implements org.hibernate.hql.spi.QueryTranslator.scroll.

Return the query results, as an instance of ScrollableResults

Parameters
queryParameters:QueryParameters

Doc from org.hibernate.hql.spi.QueryTranslator.scroll.

The query bind parameters.

session:SharedSessionContractImplementor

Doc from org.hibernate.hql.spi.QueryTranslator.scroll.

The session owning this query.

Returns:ScrollableResultsImplementor

Doc from org.hibernate.hql.spi.QueryTranslator.scroll.

The ScrollableResults wrapper around the query results.

Annotations
@Override
setEntityGraphQueryHintback to summary
public void setEntityGraphQueryHint(EntityGraphQueryHint entityGraphQueryHint)
showHqlAstback to summary
pack-priv void showHqlAst(AST hqlAst)
validateScrollabilityback to summary
public void validateScrollability() throws HibernateException

Implements org.hibernate.hql.spi.QueryTranslator.validateScrollability.

Doc from org.hibernate.hql.spi.QueryTranslator.validateScrollability.

Validate the scrollability of the translated query.

Annotations
@Override
org.hibernate.hql.internal.ast back to summary

public Class QueryTranslatorImpl.JavaConstantConverter

extends Object
implements VisitationStrategy
Class Inheritance
  • java.lang.Object
  • org.hibernate.hql.internal.ast.QueryTranslatorImpl.JavaConstantConverter
All Implemented Interfaces
org.hibernate.hql.internal.ast.util.NodeTraverser.VisitationStrategy

Field Summary

Modifier and TypeField and Description
private AST
private final SessionFactoryImplementor
factory

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Constructor Summary

AccessConstructor and Description
public
JavaConstantConverter(SessionFactoryImplementor factory)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Method Summary

Modifier and TypeMethod and Description
private void
handleDotStructure(AST dotStructureRoot)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dotRootback to summary
private AST dotRoot
factoryback to summary
private final SessionFactoryImplementor factory

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Constructor Detail

JavaConstantConverterback to summary
public JavaConstantConverter(SessionFactoryImplementor factory)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Method Detail

handleDotStructureback to summary
private void handleDotStructure(AST dotStructureRoot)
visitback to summary
public void visit(AST node)

Implements org.hibernate.hql.internal.ast.util.NodeTraverser.VisitationStrategy.visit.

Annotations
@Override