Example usage for org.hibernate.criterion Projection toSqlString

List of usage examples for org.hibernate.criterion Projection toSqlString

Introduction

In this page you can find the example usage for org.hibernate.criterion Projection toSqlString.

Prototype

public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
        throws HibernateException;

Source Link

Document

Render the SQL fragment to be used in the SELECT clause.

Usage

From source file:de.cosmocode.hibernate.CustomProjectionList.java

License:Apache License

@Override
public String toSqlString(Criteria criteria, int loc, CriteriaQuery criteriaQuery) throws HibernateException {
    final StringBuilder buf = new StringBuilder();
    for (int i = 0; i < getLength(); i++) {
        final Projection proj = getProjection(i);
        buf.append(proj.toSqlString(criteria, loc, criteriaQuery));
        proj.getColumnAliases(loc);//  www.  j  a va 2s  . co  m
        if (i < getLength() - 1 && !getProjection(i + 1).isGrouped())
            buf.append(", ");
    }
    return buf.toString();
}