Class 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 the Restrictions factory methods for generating Criterion instances
    See Also:
    Criteria
    • 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
      • 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 aliased
        alias - 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 fragment
        columnAliases - The column aliases
        types - 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 fragment
        groupBy - The SQL GROUP BY fragment
        columnAliases - The column aliases
        types - The resulting types
        Returns:
        The SQL projection
        See Also:
        SQLProjection