List of usage examples for org.hibernate NullPrecedence FIRST
NullPrecedence FIRST
To view the source code for org.hibernate NullPrecedence FIRST.
Click Source Link
From source file:net.longfalcon.newsj.persistence.hibernate.ReleaseRegexDAOImpl.java
License:Open Source License
@Override @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS) public List<ReleaseRegex> getRegexes(boolean activeOnly, String groupName, boolean userReleaseRegexes) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ReleaseRegex.class); if (activeOnly) { criteria.add(Restrictions.eq("status", 1)); }/* ww w . j a va 2 s. c o m*/ if (!ValidatorUtil.isNull(groupName)) { if (groupName.equals("all")) { criteria.add(Restrictions.isNull("groupName")); } else if (!groupName.equals("-1")) { criteria.add(Restrictions.eq("groupName", groupName)); } } if (!userReleaseRegexes) { criteria.add(Restrictions.lt("id", 100000L)); } // rough approximation of original order by: // " order by (rr.groupName like '%*') asc , coalesce(rr.groupName, 'zzz') desc , rr.ordinal asc" criteria.addOrder(Order.desc("groupName").nulls(NullPrecedence.FIRST)); criteria.addOrder(Order.asc("ordinal")); 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.//from w ww. ja v a 2s .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; } } }