org.hibernate.hql

Interface QueryTranslator

Known Subinterfaces:
FilterTranslator
Known Implementing Classes:
QueryTranslatorImpl, QueryTranslatorImpl

public interface QueryTranslator

Defines the constract of an HQL->SQL translator.
Author:
josh

Field Summary

static String
ERROR_CANNOT_DETERMINE_TYPE
static String
ERROR_CANNOT_FETCH_WITH_ITERATE
static String
ERROR_CANNOT_FORMAT_LITERAL
static String
ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR

Method Summary

List
collectSqlStrings()
void
compile(Map replacements, boolean shallow)
Compile a "normal" query.
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 defintion.
String[][]
getColumnNames()
Returns the column names in the generated SQL.
Map
getEnabledFilters()
Returns the filters enabled for this query translator.
ParameterTranslations
getParameterTranslations()
Return information about any parameters encountered during translation.
String
getQueryIdentifier()
Retrieve the query identifier for this translator.
Set
getQuerySpaces()
Returns the set of query spaces (table names) that the query referrs to.
String
getQueryString()
Returns the HQL string processed by the translator.
String[]
getReturnAliases()
Returns an array of HQL aliases
Type[]
getReturnTypes()
Returns an array of Types represented in the query result.
String
getSQLString()
Returns the SQL string generated by the translator.
boolean
isManipulationStatement()
Iterator
iterate(QueryParameters queryParameters, EventSource session)
Perform an iterate operation given the underlying query defintion.
List
list(SessionImplementor session, QueryParameters queryParameters)
Perform a list operation given the underlying query definition.
ScrollableResults
scroll(QueryParameters queryParameters, SessionImplementor session)
Perform a scroll operation given the underlying query defintion.
void
validateScrollability()
Validate the scrollability of the translated query.

Field Details

ERROR_CANNOT_DETERMINE_TYPE

public static final String ERROR_CANNOT_DETERMINE_TYPE

ERROR_CANNOT_FETCH_WITH_ITERATE

public static final String ERROR_CANNOT_FETCH_WITH_ITERATE

ERROR_CANNOT_FORMAT_LITERAL

public static final String ERROR_CANNOT_FORMAT_LITERAL

ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR

public static final String ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR

Method Details

collectSqlStrings

public List collectSqlStrings()

compile

public void compile(Map replacements,
                    boolean shallow)
            throws QueryException,
                   MappingException
Compile a "normal" query. This method may be called multiple times. Subsequent invocations are no-ops.
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.

containsCollectionFetches

public boolean containsCollectionFetches()
Does the translated query contain collection fetches?
Returns:
tru if the query does contain collection fetched; false otherwise.

executeUpdate

public int executeUpdate(QueryParameters queryParameters,
                         SessionImplementor session)
            throws HibernateException
Perform a bulk update/delete operation given the underlying query defintion.
Parameters:
queryParameters - The query bind parameters.
session - The session owning this query.
Returns:
The number of entities updated or deleted.

getColumnNames

public String[][] getColumnNames()
Returns the column names in the generated SQL.
Returns:
the column names in the generated SQL.

getEnabledFilters

public Map getEnabledFilters()
Returns the filters enabled for this query translator.
Returns:
Filters enabled for this query execution.

getParameterTranslations

public ParameterTranslations getParameterTranslations()
Return information about any parameters encountered during translation.
Returns:
The parameter information.

getQueryIdentifier

public String getQueryIdentifier()
Retrieve the query identifier for this translator. The query identifier is used in stats collection.
Returns:
the identifier

getQuerySpaces

public Set getQuerySpaces()
Returns the set of query spaces (table names) that the query referrs to.
Returns:
A set of query spaces (table names).

getQueryString

public String getQueryString()
Returns the HQL string processed by the translator.
Returns:
the HQL string processed by the translator.

getReturnAliases

public String[] getReturnAliases()
Returns an array of HQL aliases

getReturnTypes

public Type[] getReturnTypes()
Returns an array of Types represented in the query result.
Returns:
Query return types.

getSQLString

public String getSQLString()
Returns the SQL string generated by the translator.
Returns:
the SQL string generated by the translator.

isManipulationStatement

public boolean isManipulationStatement()

iterate

public Iterator iterate(QueryParameters queryParameters,
                        EventSource session)
            throws HibernateException
Perform an iterate operation given the underlying query defintion.
Parameters:
queryParameters - The query bind parameters.
session - The session owning this query.
Returns:
An iterator over the query results.

list

public List list(SessionImplementor session,
                 QueryParameters queryParameters)
            throws HibernateException
Perform a list operation given the underlying query definition.
Parameters:
session - The session owning this query.
queryParameters - The query bind parameters.
Returns:
The query list results.

scroll

public ScrollableResults scroll(QueryParameters queryParameters,
                                SessionImplementor session)
            throws HibernateException
Perform a scroll operation given the underlying query defintion.
Parameters:
queryParameters - The query bind parameters.
session - The session owning this query.
Returns:
The ScrollableResults wrapper around the query results.

validateScrollability

public void validateScrollability()
            throws HibernateException
Validate the scrollability of the translated query.