Search in sources :

Example 1 with EnhancedProjection

use of org.hibernate.criterion.EnhancedProjection in project hibernate-orm by hibernate.

the class CriteriaQueryTranslator method getColumnsUsingProjection.

/**
	 * Get the names of the columns constrained
	 * by this criterion.
	 */
@Override
public String[] getColumnsUsingProjection(Criteria subcriteria, String propertyName) throws HibernateException {
    //first look for a reference to a projection alias
    final Projection projection = rootCriteria.getProjection();
    String[] projectionColumns = null;
    if (projection != null) {
        projectionColumns = (projection instanceof EnhancedProjection ? ((EnhancedProjection) projection).getColumnAliases(propertyName, 0, rootCriteria, this) : projection.getColumnAliases(propertyName, 0));
    }
    if (projectionColumns == null) {
        //look for a property
        try {
            return getColumns(propertyName, subcriteria);
        } catch (HibernateException he) {
            //not found in inner query , try the outer query
            if (outerQueryTranslator != null) {
                return outerQueryTranslator.getColumnsUsingProjection(subcriteria, propertyName);
            } else {
                throw he;
            }
        }
    } else {
        //it refers to an alias of a projection
        return projectionColumns;
    }
}
Also used : HibernateException(org.hibernate.HibernateException) EnhancedProjection(org.hibernate.criterion.EnhancedProjection) Projection(org.hibernate.criterion.Projection) EnhancedProjection(org.hibernate.criterion.EnhancedProjection)

Aggregations

HibernateException (org.hibernate.HibernateException)1 EnhancedProjection (org.hibernate.criterion.EnhancedProjection)1 Projection (org.hibernate.criterion.Projection)1