Example usage for org.hibernate.criterion Order isIgnoreCase

List of usage examples for org.hibernate.criterion Order isIgnoreCase

Introduction

In this page you can find the example usage for org.hibernate.criterion Order isIgnoreCase.

Prototype

@SuppressWarnings("UnusedDeclaration")
    public boolean isIgnoreCase() 

Source Link

Usage

From source file:org.grails.orm.hibernate.query.AbstractHibernateQuery.java

License:Apache License

@Override
public Query order(Order order) {
    super.order(order);

    String property = order.getProperty();

    int i = property.indexOf('.');
    if (i > -1) {

        String sortHead = property.substring(0, i);
        String sortTail = property.substring(i + 1);

        if (createdAssociationPaths.containsKey(sortHead)) {
            CriteriaAndAlias criteriaAndAlias = createdAssociationPaths.get(sortHead);
            Criteria criteria = criteriaAndAlias.criteria;
            org.hibernate.criterion.Order hibernateOrder = order.getDirection() == Order.Direction.ASC
                    ? org.hibernate.criterion.Order.asc(property)
                    : org.hibernate.criterion.Order.desc(property);

            criteria.addOrder(order.isIgnoreCase() ? hibernateOrder.ignoreCase() : hibernateOrder);
        } else {//from w ww.  j  a v a 2  s  . com

            PersistentProperty persistentProperty = entity.getPropertyByName(sortHead);

            if (persistentProperty instanceof Association) {
                Association a = (Association) persistentProperty;
                if (persistentProperty instanceof Embedded) {
                    addSimpleOrder(order, property);
                } else {
                    if (criteria != null) {
                        Criteria subCriteria = criteria.createCriteria(sortHead);
                        addOrderToCriteria(subCriteria, sortTail, order);
                    } else if (detachedCriteria != null) {
                        DetachedCriteria subDetachedCriteria = detachedCriteria.createCriteria(sortHead);
                        addOrderToDetachedCriteria(subDetachedCriteria, sortTail, order);
                    }
                }
            }
        }

    } else {
        addSimpleOrder(order, property);
    }

    return this;
}

From source file:org.grails.orm.hibernate.query.AbstractHibernateQuery.java

License:Apache License

private void addOrderToDetachedCriteria(DetachedCriteria dc, String property, Order order) {
    if (dc != null) {
        org.hibernate.criterion.Order hibernateOrder = order.getDirection() == Order.Direction.ASC
                ? org.hibernate.criterion.Order.asc(calculatePropertyName(property))
                : org.hibernate.criterion.Order.desc(calculatePropertyName(property));
        dc.addOrder(order.isIgnoreCase() ? hibernateOrder.ignoreCase() : hibernateOrder);

    }/*from w w  w. j  av a2  s.  c  o  m*/
}

From source file:org.grails.orm.hibernate.query.AbstractHibernateQuery.java

License:Apache License

private void addOrderToCriteria(Criteria c, String property, Order order) {
    org.hibernate.criterion.Order hibernateOrder = order.getDirection() == Order.Direction.ASC
            ? org.hibernate.criterion.Order.asc(calculatePropertyName(property))
            : org.hibernate.criterion.Order.desc(calculatePropertyName(property));

    c.addOrder(order.isIgnoreCase() ? hibernateOrder.ignoreCase() : hibernateOrder);
}