Example usage for org.hibernate.criterion CriteriaQuery getType

List of usage examples for org.hibernate.criterion CriteriaQuery getType

Introduction

In this page you can find the example usage for org.hibernate.criterion CriteriaQuery getType.

Prototype

public Type getType(Criteria criteria, String propertyPath) throws HibernateException;

Source Link

Document

Get the type of a property path.

Usage

From source file:org.jasig.ssp.util.hibernate.MultipleCountProjection.java

License:Apache License

/**
 * Coerce a proerty to a string-ish type using the current
 * <code>Dialect</code>'s "str" function.
 *
 * @param propertyName//ww w . j a v  a2  s.co m
 * @param criteria
 * @param criteriaQuery
 * @return
 */
private String asSqlStr(String propertyName, Criteria criteria, CriteriaQuery criteriaQuery) {
    String castCall = super.getFunction("cast", criteriaQuery).render(
            criteriaQuery.getType(criteria, propertyName),
            Lists.newArrayList(
                    (String) buildFunctionParameterList(criteriaQuery.getColumn(criteria, propertyName)).get(0),
                    "string"),
            criteriaQuery.getFactory());
    return super.getFunction("coalesce", criteriaQuery).render(StringType.INSTANCE,
            Lists.newArrayList(castCall, "''"), criteriaQuery.getFactory());
}