Class SQLProjection

  • All Implemented Interfaces:
    java.io.Serializable, Projection

    public class SQLProjection
    extends java.lang.Object
    implements Projection
    A SQL fragment. The string {alias} will be replaced by the alias of the root entity.
    See Also:
    Serialized Form
    • Constructor Detail

      • SQLProjection

        protected SQLProjection​(java.lang.String sql,
                                java.lang.String[] columnAliases,
                                Type[] types)
      • SQLProjection

        protected SQLProjection​(java.lang.String sql,
                                java.lang.String groupBy,
                                java.lang.String[] columnAliases,
                                Type[] types)
    • Method Detail

      • toSqlString

        public java.lang.String toSqlString​(Criteria criteria,
                                            int loc,
                                            CriteriaQuery criteriaQuery)
        Description copied from interface: Projection
        Render the SQL fragment to be used in the SELECT clause.
        Specified by:
        toSqlString in interface Projection
        Parameters:
        criteria - The local criteria to which this project is attached (for resolution).
        loc - 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 - The overall criteria query instance.
        Returns:
        The SQL fragment to plug into the SELECT
      • toGroupSqlString

        public java.lang.String toGroupSqlString​(Criteria criteria,
                                                 CriteriaQuery criteriaQuery)
        Description copied from interface: Projection
        Render the SQL fragment to be used in the GROUP BY clause
        Specified by:
        toGroupSqlString in interface Projection
        Parameters:
        criteria - The local criteria to which this project is attached (for resolution).
        criteriaQuery - The overall criteria query instance.
        Returns:
        The SQL fragment to plug into the GROUP BY
      • getTypes

        public Type[] getTypes​(Criteria crit,
                               CriteriaQuery criteriaQuery)
        Description copied from interface: Projection
        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?
        Specified by:
        getTypes in interface Projection
        Parameters:
        crit - The local criteria to which this project is attached (for resolution).
        criteriaQuery - The overall criteria query instance.
        Returns:
        The return types.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getAliases

        public java.lang.String[] getAliases()
        Description copied from interface: Projection
        Get the criteria-level aliases for this projection (ie. the ones that will be passed to the ResultTransformer)
        Specified by:
        getAliases in interface Projection
        Returns:
        The aliases
      • isGrouped

        public boolean isGrouped()
        Description copied from interface: Projection
        Is this projection fragment (SELECT clause) also part of the GROUP BY
        Specified by:
        isGrouped in interface Projection
        Returns:
        True if the projection is also part of the GROUP BY; false otherwise.
      • getTypes

        public Type[] getTypes​(java.lang.String alias,
                               Criteria crit,
                               CriteriaQuery criteriaQuery)
        Description copied from interface: Projection
        Get the return types for a particular user-visible alias.

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

        Specified by:
        getTypes in interface Projection
        Parameters:
        alias - The criteria-level alias for which to find types.
        crit - The local criteria to which this project is attached (for resolution).
        criteriaQuery - The overall criteria query instance.
        Returns:
        The return types; expected to return null if this projection does not understand this alias.