Top Description Constructors Methods
org.hibernate.criterion

public final Class Projections

extends Object
Class Inheritance
Imports
org.hibernate.type.Type

The criterion package may be used by applications as a framework for building new kinds of Projection. However, it is intended that most applications will simply use the built-in projection types via the static factory methods of this class. The factory methods that take an alias allow the projected value to be referred to by criterion and order instances. See also the Restrictions factory methods for generating Criterion instances
Authors
Gavin King, Steve Ebersole
See Also
org.hibernate.Criteria

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Projection

Returns:

The aliased projection
alias
(Projection
The projection to be aliased
projection
,
String
The alias to apply
alias
)

Assign an alias to a projection, by wrapping it

public static AggregateProjection

Returns:

the avg projection
avg
(String
The property over which to find the average
propertyName
)

A property average value projection

public static CountProjection

Returns:

The count projection
count
(String
The name of the property to count over
propertyName
)

A property value count projection

public static CountProjection

Returns:

The count projection
countDistinct
(String
The name of the property to count over
propertyName
)

A distinct property value count projection

public static Projection

Returns:

The distinct projection
distinct
(Projection
The project to treat distinctly
projection
)

Create a distinct projection from a projection.

public static ForeingKeyProjection
fk(String associationPropertyName)

public static PropertyProjection

Returns:

The grouped projection
groupProperty
(String
The name of the property to group
propertyName
)

A grouping property value projection

public static IdentifierProjection

Returns:

The identifier projection
id
()

An identifier value projection.

public static AggregateProjection

Returns:

the max projection
max
(String
The property for which to find the max
propertyName
)

A property maximum value projection

public static AggregateProjection

Returns:

the min projection
min
(String
The property for which to find the min
propertyName
)

A property minimum value projection

public static ProjectionList

Returns:

The projection list
projectionList
()

Create a new projection list.

public static PropertyProjection

Returns:

The property projection
property
(String
The name of the property whose values should be projected
propertyName
)

A property value projection

public static Projection

Returns:

The projection representing the row count
rowCount
()

The query row count, ie.

public static Projection

Returns:

The SQL projection
sqlGroupProjection
(String
The SQL SELECT fragment
sql
,
String
The SQL GROUP BY fragment
groupBy
,
String[]
The column aliases
columnAliases
,
Type[]
The resulting types
types
)

A grouping SQL projection, specifying both select clause and group by clause fragments

public static Projection

Returns:

The SQL projection
sqlProjection
(String
The SQL fragment
sql
,
String[]
The column aliases
columnAliases
,
Type[]
The resulting types
types
)

A SQL projection, a typed select clause fragment

public static AggregateProjection

Returns:

the sum projection
sum
(String
The property over which to sum
propertyName
)

A property value sum projection

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Projectionsback to summary
private Projections()

Method Detail

aliasback to summary
public static Projection alias(Projection projection, String alias)

Assign an alias to a projection, by wrapping it

Parameters
projection:Projection

The projection to be aliased

alias:String

The alias to apply

Returns:Projection

The aliased projection

See Also
AliasedProjection
avgback to summary
public static AggregateProjection avg(String propertyName)

A property average value projection

Parameters
propertyName:String

The property over which to find the average

Returns:AggregateProjection

the avg projection

See Also
AvgProjection
countback to summary
public static CountProjection count(String propertyName)

A property value count projection

Parameters
propertyName:String

The name of the property to count over

Returns:CountProjection

The count projection

See Also
CountProjection
countDistinctback to summary
public static CountProjection countDistinct(String propertyName)

A distinct property value count projection

Parameters
propertyName:String

The name of the property to count over

Returns:CountProjection

The count projection

See Also
CountProjection
distinctback to summary
public static Projection distinct(Projection projection)

Create a distinct projection from a projection.

Parameters
projection:Projection

The project to treat distinctly

Returns:Projection

The distinct projection

See Also
Distinct
fkback to summary
public static ForeingKeyProjection fk(String associationPropertyName)
groupPropertyback to summary
public static PropertyProjection groupProperty(String propertyName)

A grouping property value projection

Parameters
propertyName:String

The name of the property to group

Returns:PropertyProjection

The grouped projection

See Also
PropertyProjection
idback to summary
public static IdentifierProjection id()

An identifier value projection.

Returns:IdentifierProjection

The identifier projection

See Also
IdentifierProjection
maxback to summary
public static AggregateProjection max(String propertyName)

A property maximum value projection

Parameters
propertyName:String

The property for which to find the max

Returns:AggregateProjection

the max projection

See Also
AggregateProjection
minback to summary
public static AggregateProjection min(String propertyName)

A property minimum value projection

Parameters
propertyName:String

The property for which to find the min

Returns:AggregateProjection

the min projection

See Also
AggregateProjection
projectionListback to summary
public static ProjectionList projectionList()

Create a new projection list.

Returns:ProjectionList

The projection list

propertyback to summary
public static PropertyProjection property(String propertyName)

A property value projection

Parameters
propertyName:String

The name of the property whose values should be projected

Returns:PropertyProjection

The property projection

See Also
PropertyProjection
rowCountback to summary
public static Projection rowCount()

The query row count, ie. count(*)

Returns:Projection

The projection representing the row count

See Also
RowCountProjection
sqlGroupProjectionback to summary
public static Projection sqlGroupProjection(String sql, String groupBy, String[] columnAliases, Type[] types)

A grouping SQL projection, specifying both select clause and group by clause fragments

Parameters
sql:String

The SQL SELECT fragment

groupBy:String

The SQL GROUP BY fragment

columnAliases:String[]

The column aliases

types:Type[]

The resulting types

Returns:Projection

The SQL projection

Annotations
@SuppressWarnings:UnusedDeclaration
See Also
SQLProjection
sqlProjectionback to summary
public static Projection sqlProjection(String sql, String[] columnAliases, Type[] types)

A SQL projection, a typed select clause fragment

Parameters
sql:String

The SQL fragment

columnAliases:String[]

The column aliases

types:Type[]

The resulting types

Returns:Projection

The SQL projection

See Also
SQLProjection
sumback to summary
public static AggregateProjection sum(String propertyName)

A property value sum projection

Parameters
propertyName:String

The property over which to sum

Returns:AggregateProjection

the sum projection

See Also
AggregateProjection