Top Description Fields Constructors Methods
org.hibernate.hql.classic

public Class QueryTranslatorImpl

extends BasicLoader
implements FilterTranslator
Class Inheritance
All Implemented Interfaces
org.hibernate.hql.FilterTranslator, org.hibernate.hql.QueryTranslator
Imports
java.io.Serializable, java.lang.reflect.Constructor, java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.ArrayList, .HashMap, .HashSet, .Iterator, .LinkedHashMap, .List, .Map, .Set, org.slf4j.Logger, .LoggerFactory, org.hibernate.HibernateException, .LockMode, .MappingException, .QueryException, .ScrollableResults, .LockOptions, org.hibernate.dialect.Dialect, org.hibernate.engine.JoinSequence, .QueryParameters, .SessionFactoryImplementor, .SessionImplementor, org.hibernate.event.EventSource, org.hibernate.exception.JDBCExceptionHelper, org.hibernate.hql.FilterTranslator, .HolderInstantiator, .NameGenerator, .ParameterTranslations, org.hibernate.impl.IteratorImpl, org.hibernate.loader.BasicLoader, org.hibernate.persister.collection.CollectionPersister, .QueryableCollection, org.hibernate.persister.entity.Loadable, .PropertyMapping, .Queryable, org.hibernate.sql.JoinFragment, .QuerySelect, org.hibernate.transform.ResultTransformer, org.hibernate.type.AssociationType, .EntityType, .Type, .TypeFactory, org.hibernate.util.ArrayHelper, .ReflectHelper, .StringHelper

An instance of QueryTranslator translates a Hibernate query string to SQL.

Field Summary

Modifier and TypeField and Description
private Type[]
private final Map<K, V>
private int
private String
private QueryableCollection
private final Map<K, V>
private boolean
private final Map<K, V>
private boolean
private Map<K, V>
private final Set<E>
private String
private final List<E>
private final List<E>
private boolean
private final List<E>
private Class<T>
private Constructor<T>
private boolean[]
private final Map<K, V>
private static final Logger
private int
private final Map<K, V>
private String[]
private static final String[]
private final Map<K, V>
private final List<E>
private EntityType[]
private int[]
private int
private final Map<K, V>
private final Map<K, V>
private Queryable[]
private final String
private final Set<E>
private final String
private List<E>
private Type[]
private String[][]
private final List<E>
private final List<E>
private int
private boolean
private String
private String[]
private QueryTranslatorImpl
private Map<K, V>
private final Map<K, V>
private final Map<K, V>
private final List<E>
Inherited from org.hibernate.loader.BasicLoader:
NO_SUFFIX

Constructor Summary

AccessConstructor and Description
public
QueryTranslatorImpl(String
A unique identifier for the query of which this translation is part; typically this is the original, user-supplied query string.
queryIdentifier
,
String
The "preprocessed" query string; at the very least already processed by org.hibernate.hql.QuerySplitter.
queryString
,
Map<K, V>
Any enabled filters.
enabledFilters
,
SessionFactoryImplementor
The session factory.
factory
)

Construct a query translator

public
QueryTranslatorImpl(String
The query string to process.
queryString
,
Map<K, V>
Any enabled filters.
enabledFilters
,
SessionFactoryImplementor
The session factory.
factory
)

Construct a query translator; this form used internally.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
addEntityToFetch(String name, String oneToOneOwnerName, AssociationType ownerAssociationType)

private void
pack-priv void
addFrom(String name, String type, JoinSequence joinSequence)

pack-priv void
addFrom(String name, JoinSequence joinSequence)

private void
addFromAssociation(final String elementName, final String collectionRole)

Used for collection filters

pack-priv void
addFromClass(String name, Queryable classPersister)

pack-priv void
addFromCollection(String name, String collectionRole, JoinSequence joinSequence)

pack-priv void
addFromJoinOnly(String name, JoinSequence joinSequence)

pack-priv void
addJoin(String name, JoinSequence joinSequence)

pack-priv void
pack-priv void
addPathAliasAndJoin(String path, String alias, JoinSequence joinSequence)

pack-priv void
pack-priv void
pack-priv void
pack-priv void
addType(String name, String type)

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
protected String
applyLocks(String sql, LockOptions lockOptions, Dialect dialect)

Overrides org.hibernate.loader.Loader.applyLocks.

Append FOR UPDATE OF clause, if necessary.
public List<E>
pack-priv void
compile(QueryTranslatorImpl
The containing query of the query to be compiled.
superquery
)

Compile a subquery.

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

Implements org.hibernate.hql.QueryTranslator.compile.

Compile a "normal" query.
public synchronized 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?
scalar
)

Implements org.hibernate.hql.FilterTranslator.compile.

Compile a filter.
private void
compile()

Compile the query (generate the SQL).

public boolean
containsCollectionFetches()

Implements org.hibernate.hql.QueryTranslator.containsCollectionFetches.

Does the translated query contain collection fetches?
pack-priv String
pack-priv String
pack-priv void
public int
executeUpdate(QueryParameters
The query bind parameters.
queryParameters
,
SessionImplementor
The session owning this query.
session
)

Implements org.hibernate.hql.QueryTranslator.executeUpdate.

Perform a bulk update/delete operation given the underlying query definition.
protected String[]
getAliases()

Overrides org.hibernate.loader.Loader.getAliases.

Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading
public String
protected int[]
getCollectionOwners()

Overrides org.hibernate.loader.Loader.getCollectionOwners.

Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie.
pack-priv QueryableCollection
public CollectionPersister[]
protected String[]
public String[][]
getColumnNames()

Implements org.hibernate.hql.QueryTranslator.getColumnNames.

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

Implements org.hibernate.hql.QueryTranslator.getEnabledFilters.

Returns the filters enabled for this query translator.
pack-priv Queryable
private Queryable
protected Loadable[]

Returns:

an array of EntityPersisters.
getEntityPersisters
()

Implements abstract org.hibernate.loader.Loader.getEntityPersisters.

Persisters for the return values of a find() style query.
pack-priv Queryable
public Class<T>
protected LockMode[]
getLockModes(LockOptions
a collection of lock options specified dynamically via the Query interface
lockOptions
)

Implements abstract org.hibernate.loader.Loader.getLockModes.

What lock options does this load entities with?
public int[]
protected EntityType[]
getOwnerAssociationTypes()

Overrides org.hibernate.loader.Loader.getOwnerAssociationTypes.

An array of the owner types corresponding to the getOwners() returns.
protected int[]
getOwners()

Overrides org.hibernate.loader.Loader.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").
public ParameterTranslations
getParameterTranslations()

Implements org.hibernate.hql.QueryTranslator.getParameterTranslations.

Return information about any parameters encountered during translation.
pack-priv String
pack-priv JoinSequence
pack-priv PropertyMapping
public String
getQueryIdentifier()

Overrides org.hibernate.loader.Loader.getQueryIdentifier.

Implements org.hibernate.hql.QueryTranslator.getQueryIdentifier.

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

Implements org.hibernate.hql.QueryTranslator.getQuerySpaces.

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

Implements org.hibernate.hql.QueryTranslator.getQueryString.

Returns the HQL string processed by the translator.
protected Object
getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)

Overrides org.hibernate.loader.Loader.getResultColumnOrRow.

Get the actual object that is returned in the user-visible result list.
protected List<E>
public String[]
getReturnAliases()

Implements org.hibernate.hql.QueryTranslator.getReturnAliases.

Returns an array of HQL aliases
public Type[]

Returns:

an array of Types.
getReturnTypes
()

Implements org.hibernate.hql.QueryTranslator.getReturnTypes.

Types of the return values of an iterate() style query.
private String
public String
getSQLString()

Implements abstract org.hibernate.loader.Loader.getSQLString.

Implements org.hibernate.hql.QueryTranslator.getSQLString.

Returns the SQL string generated by the translator.
protected String[]
private String
protected boolean
public boolean
pack-priv boolean
isName(String name)

pack-priv boolean

Returns:

true if it is, false if it is called by find() or list()
isShallowQuery
()

Is this query called by scroll() or iterate()?

pack-priv boolean
protected boolean
public Iterator<E>
iterate(QueryParameters
The query bind parameters.
queryParameters
,
EventSource
The session owning this query.
session
)

Implements org.hibernate.hql.QueryTranslator.iterate.

Return the query results as an iterator
public List<E>
list(SessionImplementor
The session owning this query.
session
,
QueryParameters
The query bind parameters.
queryParameters
)

Implements org.hibernate.hql.QueryTranslator.list.

Perform a list operation given the underlying query definition.
private static void
private void
private int
private void
private void
private String
renderScalarSelect()

Warning

side-effecty

private void
protected ResultTransformer
resolveResultTransformer(ResultTransformer
the specified result transformer
resultTransformer
)

Overrides org.hibernate.loader.Loader.resolveResultTransformer.

Determine the actual ResultTransformer that will be used to transform query results.
public ScrollableResults
scroll(final QueryParameters
The query bind parameters.
queryParameters
,
final SessionImplementor
The session owning this query.
session
)

Implements org.hibernate.hql.QueryTranslator.scroll.

Perform a scroll operation given the underlying query definition.
pack-priv void
setAliasName(String alias, String name)

pack-priv void
setCollectionToFetch(String role, String name, String ownerName, String entityName)

pack-priv void
setDistinct(boolean distinct)

pack-priv void
private Object[]
public String
toString()

Overrides org.hibernate.loader.Loader.toString.

Returns a string representation of the object.
pack-priv String
protected boolean
upgradeLocks()

Overrides org.hibernate.loader.Loader.upgradeLocks.

Does this query return objects that might be already cached by the session, whose lock mode may need upgrading
public void
validateScrollability()

Implements org.hibernate.hql.QueryTranslator.validateScrollability.

Validate the scrollability of the translated query.
Inherited from org.hibernate.loader.BasicLoader:
generateSuffixesgenerateSuffixesgetCollectionAliasesgetEntityAliasespostInstantiate