Example usage for org.hibernate NullPrecedence LAST

List of usage examples for org.hibernate NullPrecedence LAST

Introduction

In this page you can find the example usage for org.hibernate NullPrecedence LAST.

Prototype

NullPrecedence LAST

To view the source code for org.hibernate NullPrecedence LAST.

Click Source Link

Document

Null values appear at the end of the sorted collection.

Usage

From source file:net.longfalcon.newsj.persistence.hibernate.BinaryBlacklistDAOImpl.java

License:Open Source License

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<BinaryBlacklistEntry> findAllBinaryBlacklistEntries(boolean activeOnly) {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(BinaryBlacklistEntry.class);
    if (activeOnly) {
        criteria.add(Restrictions.eq("status", 1));
    }// w  w w  . ja va 2  s .  c o  m
    criteria.addOrder(Order.asc("groupName").nulls(NullPrecedence.LAST));

    return criteria.list();
}

From source file:org.squashtest.tm.service.internal.foundation.collection.SortingUtils.java

License:Open Source License

/**
 * Adds sorting to a Criteria query.// w  w w. j a v a 2  s  . co  m
 *
 * @param criteria
 * @param sorting
 */
public static void addOrder(Criteria criteria, Sorting sorting) {
    if (!StringUtils.isBlank(sorting.getSortedAttribute())) {
        switch (sorting.getSortOrder()) {
        case ASCENDING:
            criteria.addOrder(Order.asc(sorting.getSortedAttribute()).nulls(NullPrecedence.FIRST));
            break;
        case DESCENDING:
            criteria.addOrder(Order.desc(sorting.getSortedAttribute()).nulls(NullPrecedence.LAST));
            break;
        }
    }
}