Top Description Methods
org.hibernate.criterion

public Interface Projection

extends Serializable
Known Direct Subinterfaces
org.hibernate.criterion.EnhancedProjection
Known Direct Implementers
org.hibernate.criterion.SQLProjection
Imports
java.io.Serializable, org.hibernate.Criteria, .HibernateException, org.hibernate.type.Type

An object-oriented representation of a query result set projection in a Criteria query. Built-in projection types are provided by the Projections factory class. This interface might be implemented by application classes that define custom projections.
Authors
Gavin King, Steve Ebersole
See Also
Projections, Criteria

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

The aliases
getAliases
()

Get the criteria-level aliases for this projection (ie.

public String[]

Returns:

The columns aliases.
getColumnAliases
(int
Just as in toSqlString, represents the number of columns rendered prior to this projection.
position
)

Get the SQL column aliases used by this projection for the columns it writes for inclusion into the SELECT clause (toSqlString.

public String[]

Returns:

The columns aliases pertaining to a particular criteria-level alias; expected to return null if this projection does not understand this alias.
getColumnAliases
(String
The criteria-level alias
alias
,
int
Just as in toSqlString, represents the number of columns rendered prior to this projection.
position
)

Get the SQL column aliases used by this projection for the columns it writes for inclusion into the SELECT clause (toSqlString for a particular criteria-level alias.

public Type[]

Returns:

The return types.
getTypes
(Criteria
The local criteria to which this project is attached (for resolution).
criteria
,
CriteriaQuery
The overall criteria query instance.
criteriaQuery
)

Types returned by the rendered SQL fragment.

public Type[]

Returns:

The return types; expected to return null if this projection does not understand this alias.
getTypes
(String
The criteria-level alias for which to find types.
alias
,
Criteria
The local criteria to which this project is attached (for resolution).
criteria
,
CriteriaQuery
The overall criteria query instance.
criteriaQuery
)

Get the return types for a particular user-visible alias.

public boolean

Returns:

True if the projection is also part of the GROUP BY; false otherwise.
isGrouped
()

Is this projection fragment (SELECT clause) also part of the GROUP BY

public String

Returns:

The SQL fragment to plug into the GROUP BY
toGroupSqlString
(Criteria
The local criteria to which this project is attached (for resolution).
criteria
,
CriteriaQuery
The overall criteria query instance.
criteriaQuery
)

Render the SQL fragment to be used in the GROUP BY clause

public String

Returns:

The SQL fragment to plug into the SELECT
toSqlString
(Criteria
The local criteria to which this project is attached (for resolution).
criteria
,
int
The number of columns rendered in the SELECT clause before this projection. Generally speaking this is useful to ensure uniqueness of the individual columns aliases.
position
,
CriteriaQuery
The overall criteria query instance.
criteriaQuery
)

Render the SQL fragment to be used in the SELECT clause.

Method Detail

getAliasesback to summary
public String[] getAliases()

Get the criteria-level aliases for this projection (ie. the ones that will be passed to the org.hibernate.transform.ResultTransformer)

Returns:String[]

The aliases

getColumnAliasesback to summary
public String[] getColumnAliases(int position)

Get the SQL column aliases used by this projection for the columns it writes for inclusion into the SELECT clause (toSqlString. Hibernate always uses column aliases to extract data from the JDBC java.sql.ResultSet, so it is important that these be implemented correctly in order for Hibernate to be able to extract these val;ues correctly.

Parameters
position:int

Just as in toSqlString, represents the number of columns rendered prior to this projection.

Returns:String[]

The columns aliases.

getColumnAliasesback to summary
public String[] getColumnAliases(String alias, int position)

Get the SQL column aliases used by this projection for the columns it writes for inclusion into the SELECT clause (toSqlString for a particular criteria-level alias.

Parameters
alias:String

The criteria-level alias

position:int

Just as in toSqlString, represents the number of columns rendered prior to this projection.

Returns:String[]

The columns aliases pertaining to a particular criteria-level alias; expected to return null if this projection does not understand this alias.

getTypesback to summary
public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException

Types returned by the rendered SQL fragment. In other words what are the types that would represent the values this projection asked to be pulled into the result set?

Parameters
criteria:Criteria

The local criteria to which this project is attached (for resolution).

criteriaQuery:CriteriaQuery

The overall criteria query instance.

Returns:Type[]

The return types.

Exceptions
HibernateException:
Indicates a problem resolving the types
getTypesback to summary
public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException

Get the return types for a particular user-visible alias.

Differs from getTypes(org.hibernate.Criteria, CriteriaQuery) in that here we are only interested in the types related to the given criteria-level alias.

Parameters
alias:String

The criteria-level alias for which to find types.

criteria:Criteria

The local criteria to which this project is attached (for resolution).

criteriaQuery:CriteriaQuery

The overall criteria query instance.

Returns:Type[]

The return types; expected to return null if this projection does not understand this alias.

Exceptions
HibernateException:
Indicates a problem resolving the types
isGroupedback to summary
public boolean isGrouped()

Is this projection fragment (SELECT clause) also part of the GROUP BY

Returns:boolean

True if the projection is also part of the GROUP BY; false otherwise.

toGroupSqlStringback to summary
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException

Render the SQL fragment to be used in the GROUP BY clause

Parameters
criteria:Criteria

The local criteria to which this project is attached (for resolution).

criteriaQuery:CriteriaQuery

The overall criteria query instance.

Returns:String

The SQL fragment to plug into the GROUP BY

Exceptions
HibernateException:
Indicates a problem performing the rendering
toSqlStringback to summary
public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery) throws HibernateException

Render the SQL fragment to be used in the SELECT clause.

Parameters
criteria:Criteria

The local criteria to which this project is attached (for resolution).

position:int

The number of columns rendered in the SELECT clause before this projection. Generally speaking this is useful to ensure uniqueness of the individual columns aliases.

criteriaQuery:CriteriaQuery

The overall criteria query instance.

Returns:String

The SQL fragment to plug into the SELECT

Exceptions
HibernateException:
Indicates a problem performing the rendering