Top Description Fields Constructors Methods
org.hibernate.criterion

public abstract Class SimpleProjection

extends Object
implements EnhancedProjection
Class Inheritance
All Implemented Interfaces
org.hibernate.criterion.EnhancedProjection, org.hibernate.criterion.Projection, java.io.Serializable
Known Direct Subclasses
org.hibernate.criterion.AggregateProjection, org.hibernate.criterion.ForeingKeyProjection, org.hibernate.criterion.IdentifierProjection, org.hibernate.criterion.PropertyProjection, org.hibernate.criterion.RowCountProjection
Imports
org.hibernate.Criteria, org.hibernate.type.Type

A single-column projection that may be aliased
Author
Gavin King

Field Summary

Modifier and TypeField and Description
private static final int
private static final String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
aliasForLocation(final int loc)

public Projection

Returns:

The aliased projection
as
(String
The alias to apply
alias
)

Create an aliased form of this projection

public String[]
getAliases()

Implements org.hibernate.criterion.Projection.getAliases.

Get the criteria-level aliases for this projection (ie.
private static String
getAliasForLocation(final int loc)

public String[]
getColumnAliases(String
The criteria-level alias
alias
,
int
Just as in toSqlString, represents the number of columns rendered prior to this projection.
loc
)

Implements org.hibernate.criterion.Projection.getColumnAliases.

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 String[]
getColumnAliases(String
The criteria-level alias
alias
,
int
Just as in toSqlString, represents the number of columns rendered prior to this projection.
loc
,
Criteria
The local criteria to which this project is attached (for resolution).
criteria
,
CriteriaQuery
The overall criteria query instance.
criteriaQuery
)

Implements org.hibernate.criterion.EnhancedProjection.getColumnAliases.

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 String[]
getColumnAliases(int
Just as in toSqlString, represents the number of columns rendered prior to this projection.
loc
)

Implements org.hibernate.criterion.Projection.getColumnAliases.

Get the SQL column aliases used by this projection for the columns it writes for inclusion into the SELECT clause (toSqlString.
public String[]
getColumnAliases(int
Just as in toSqlString, represents the number of columns rendered prior to this projection.
loc
,
Criteria
The local criteria to which this project is attached (for resolution).
criteria
,
CriteriaQuery
The overall criteria query instance.
criteriaQuery
)

Implements org.hibernate.criterion.EnhancedProjection.getColumnAliases.

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

Returns:

The number of columns
getColumnCount
(Criteria
The criteria
criteria
,
CriteriaQuery
The query
criteriaQuery
)

Count the number of columns this projection uses.

public Type[]
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
)

Implements org.hibernate.criterion.Projection.getTypes.

Get the return types for a particular user-visible alias.
private static String[]
public boolean
isGrouped()

Implements org.hibernate.criterion.Projection.isGrouped.

Is this projection fragment (SELECT clause) also part of the GROUP BY
public String
toGroupSqlString(Criteria
The local criteria to which this project is attached (for resolution).
criteria
,
CriteriaQuery
The overall criteria query instance.
criteriaQuery
)

Implements org.hibernate.criterion.Projection.toGroupSqlString.

Render the SQL fragment to be used in the GROUP BY clause
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NUM_REUSABLE_ALIASESback to summary
private static final int NUM_REUSABLE_ALIASES
REUSABLE_ALIASESback to summary
private static final String[] REUSABLE_ALIASES

Constructor Detail

SimpleProjectionback to summary
public SimpleProjection()

Method Detail

aliasForLocationback to summary
private static String aliasForLocation(final int loc)
asback to summary
public Projection as(String alias)

Create an aliased form of this projection

Parameters
alias:String

The alias to apply

Returns:Projection

The aliased projection

getAliasesback to summary
public String[] getAliases()

Implements org.hibernate.criterion.Projection.getAliases.

Doc from org.hibernate.criterion.Projection.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

Annotations
@Override
getAliasForLocationback to summary
private static String getAliasForLocation(final int loc)
getColumnAliasesback to summary
public String[] getColumnAliases(String alias, int loc)

Implements org.hibernate.criterion.Projection.getColumnAliases.

Doc from org.hibernate.criterion.Projection.getColumnAliases.

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

loc: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.

Annotations
@Override
getColumnAliasesback to summary
public String[] getColumnAliases(String alias, int loc, Criteria criteria, CriteriaQuery criteriaQuery)

Implements org.hibernate.criterion.EnhancedProjection.getColumnAliases.

Doc from org.hibernate.criterion.EnhancedProjection.getColumnAliases.

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

loc:int

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

criteria:Criteria

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

criteriaQuery:CriteriaQuery

The overall criteria query instance.

Returns:String[]

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

Annotations
@Override
getColumnAliasesback to summary
public String[] getColumnAliases(int loc)

Implements org.hibernate.criterion.Projection.getColumnAliases.

Doc from org.hibernate.criterion.Projection.getColumnAliases.

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 values correctly.

Parameters
loc:int

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

Returns:String[]

The columns aliases.

Annotations
@Override
getColumnAliasesback to summary
public String[] getColumnAliases(int loc, Criteria criteria, CriteriaQuery criteriaQuery)

Implements org.hibernate.criterion.EnhancedProjection.getColumnAliases.

Doc from org.hibernate.criterion.EnhancedProjection.getColumnAliases.

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 values correctly.

Parameters
loc:int

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

criteria:Criteria

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

criteriaQuery:CriteriaQuery

The overall criteria query instance.

Returns:String[]

The columns aliases.

Annotations
@Override
getColumnCountback to summary
public int getColumnCount(Criteria criteria, CriteriaQuery criteriaQuery)

Count the number of columns this projection uses.

Parameters
criteria:Criteria

The criteria

criteriaQuery:CriteriaQuery

The query

Returns:int

The number of columns

getTypesback to summary
public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)

Implements org.hibernate.criterion.Projection.getTypes.

Doc from org.hibernate.criterion.Projection.getTypes.

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.

Annotations
@Override
initializeReusableAliasesback to summary
private static String[] initializeReusableAliases()
isGroupedback to summary
public boolean isGrouped()

Implements org.hibernate.criterion.Projection.isGrouped.

Doc from org.hibernate.criterion.Projection.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.

Annotations
@Override
toGroupSqlStringback to summary
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)

Implements org.hibernate.criterion.Projection.toGroupSqlString.

Doc from org.hibernate.criterion.Projection.toGroupSqlString.

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

Annotations
@Override