Example usage for org.hibernate.criterion CriteriaQuery getIdentifierType

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

Introduction

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

Prototype

public Type getIdentifierType(Criteria criteria);

Source Link

Document

Get the identifier type of this entity

Usage

From source file:common.util.db.MonthEqExpression.java

@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    return new TypedValue[] {
            new TypedValue(criteriaQuery.getIdentifierType(criteria), month, EntityMode.POJO) };
}

From source file:common.util.db.MonthGroupExpression.java

@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    return new TypedValue[] { new TypedValue(criteriaQuery.getIdentifierType(criteria), EntityMode.POJO) };
}

From source file:common.util.db.YearEqExpression.java

@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
    return new TypedValue[] {
            new TypedValue(criteriaQuery.getIdentifierType(criteria), year, EntityMode.POJO) };
}

From source file:edu.utah.further.core.data.hibernate.query.GroupByHavingProjection.java

License:Apache License

@Override
public String toSqlString(final Criteria criteria, final int position, final CriteriaQuery criteriaQuery)
        throws HibernateException {
    final Type identifierType = criteriaQuery.getIdentifierType(criteria);
    if (identifierType.isComponentType()) {
        final StringBuffer sb = new StringBuffer();
        appendComponentIds(sb, (ComponentType) identifierType, criteriaQuery, criteria, new Integer(position));
        return sb.toString();
    }// w  w  w. j a v  a  2 s . c om
    return super.toSqlString(criteria, position, criteriaQuery);

}

From source file:edu.utah.further.core.data.hibernate.query.GroupByHavingProjection.java

License:Apache License

@Override
public String toGroupSqlString(final Criteria criteria, final CriteriaQuery criteriaQuery)
        throws HibernateException {
    final StringBuffer sb = new StringBuffer(50);

    final Type identifierType = criteriaQuery.getIdentifierType(criteria);
    if (identifierType.isComponentType()) {
        appendComponentIds(sb, (ComponentType) identifierType, criteriaQuery, criteria, null);
    } else {/*from w  ww  . ja  v a2s.c o m*/
        sb.append(criteriaQuery.getColumn(criteria, groupByProperty));
    }

    // Append HAVING clause
    sb.append(" having ");
    sb.append("(");
    // Remove the alias
    final String proj = projection.toSqlString(criteria, 0xCAFEBABE, criteriaQuery);
    sb.append(proj.substring(0, proj.indexOf("as")).trim());
    sb.append(")");

    sb.append(SPACE_STRING).append(op.getSqloperator()).append(SPACE_STRING).append(value);

    return sb.toString();
}