Package org.hibernate.criterion
Class Projections
- java.lang.Object
-
- org.hibernate.criterion.Projections
-
public final class Projections extends java.lang.Object
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 theRestrictions
factory methods for generatingCriterion
instances- See Also:
Criteria
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Projection
alias(Projection projection, java.lang.String alias)
Assign an alias to a projection, by wrapping itstatic AggregateProjection
avg(java.lang.String propertyName)
A property average value projectionstatic CountProjection
count(java.lang.String propertyName)
A property value count projectionstatic CountProjection
countDistinct(java.lang.String propertyName)
A distinct property value count projectionstatic Projection
distinct(Projection projection)
Create a distinct projection from a projection.static ForeingKeyProjection
fk(java.lang.String associationPropertyName)
static PropertyProjection
groupProperty(java.lang.String propertyName)
A grouping property value projectionstatic IdentifierProjection
id()
An identifier value projection.static AggregateProjection
max(java.lang.String propertyName)
A property maximum value projectionstatic AggregateProjection
min(java.lang.String propertyName)
A property minimum value projectionstatic ProjectionList
projectionList()
Create a new projection list.static PropertyProjection
property(java.lang.String propertyName)
A property value projectionstatic Projection
rowCount()
The query row count, ie.static Projection
sqlGroupProjection(java.lang.String sql, java.lang.String groupBy, java.lang.String[] columnAliases, Type[] types)
A grouping SQL projection, specifying both select clause and group by clause fragmentsstatic Projection
sqlProjection(java.lang.String sql, java.lang.String[] columnAliases, Type[] types)
A SQL projection, a typed select clause fragmentstatic AggregateProjection
sum(java.lang.String propertyName)
A property value sum projection
-
-
-
Method Detail
-
property
public static PropertyProjection property(java.lang.String propertyName)
A property value projection- Parameters:
propertyName
- The name of the property whose values should be projected- Returns:
- The property projection
- See Also:
PropertyProjection
-
groupProperty
public static PropertyProjection groupProperty(java.lang.String propertyName)
A grouping property value projection- Parameters:
propertyName
- The name of the property to group- Returns:
- The grouped projection
- See Also:
PropertyProjection
-
id
public static IdentifierProjection id()
An identifier value projection.- Returns:
- The identifier projection
- See Also:
IdentifierProjection
-
fk
public static ForeingKeyProjection fk(java.lang.String associationPropertyName)
-
distinct
public static Projection distinct(Projection projection)
Create a distinct projection from a projection.- Parameters:
projection
- The project to treat distinctly- Returns:
- The distinct projection
- See Also:
Distinct
-
projectionList
public static ProjectionList projectionList()
Create a new projection list.- Returns:
- The projection list
-
rowCount
public static Projection rowCount()
The query row count, ie. count(*)- Returns:
- The projection representing the row count
- See Also:
RowCountProjection
-
count
public static CountProjection count(java.lang.String propertyName)
A property value count projection- Parameters:
propertyName
- The name of the property to count over- Returns:
- The count projection
- See Also:
CountProjection
-
countDistinct
public static CountProjection countDistinct(java.lang.String propertyName)
A distinct property value count projection- Parameters:
propertyName
- The name of the property to count over- Returns:
- The count projection
- See Also:
CountProjection
-
max
public static AggregateProjection max(java.lang.String propertyName)
A property maximum value projection- Parameters:
propertyName
- The property for which to find the max- Returns:
- the max projection
- See Also:
AggregateProjection
-
min
public static AggregateProjection min(java.lang.String propertyName)
A property minimum value projection- Parameters:
propertyName
- The property for which to find the min- Returns:
- the min projection
- See Also:
AggregateProjection
-
avg
public static AggregateProjection avg(java.lang.String propertyName)
A property average value projection- Parameters:
propertyName
- The property over which to find the average- Returns:
- the avg projection
- See Also:
AvgProjection
-
sum
public static AggregateProjection sum(java.lang.String propertyName)
A property value sum projection- Parameters:
propertyName
- The property over which to sum- Returns:
- the sum projection
- See Also:
AggregateProjection
-
alias
public static Projection alias(Projection projection, java.lang.String alias)
Assign an alias to a projection, by wrapping it- Parameters:
projection
- The projection to be aliasedalias
- The alias to apply- Returns:
- The aliased projection
- See Also:
AliasedProjection
-
sqlProjection
public static Projection sqlProjection(java.lang.String sql, java.lang.String[] columnAliases, Type[] types)
A SQL projection, a typed select clause fragment- Parameters:
sql
- The SQL fragmentcolumnAliases
- The column aliasestypes
- The resulting types- Returns:
- The SQL projection
- See Also:
SQLProjection
-
sqlGroupProjection
public static Projection sqlGroupProjection(java.lang.String sql, java.lang.String groupBy, java.lang.String[] columnAliases, Type[] types)
A grouping SQL projection, specifying both select clause and group by clause fragments- Parameters:
sql
- The SQL SELECT fragmentgroupBy
- The SQL GROUP BY fragmentcolumnAliases
- The column aliasestypes
- The resulting types- Returns:
- The SQL projection
- See Also:
SQLProjection
-
-