protected void updatePagingAndSortingByOid( RootHibernateQuery hibernateQuery, ObjectPagingAfterOid paging) { String rootAlias = hibernateQuery.getPrimaryEntityAlias(); if (paging.getOrderBy() != null || paging.getDirection() != null || paging.getOffset() != null) { throw new IllegalArgumentException( "orderBy, direction nor offset is allowed on ObjectPagingAfterOid"); } hibernateQuery.addOrdering(rootAlias + ".oid", OrderDirection.ASCENDING); if (paging.getMaxSize() != null) { hibernateQuery.setMaxResults(paging.getMaxSize()); } }
public <T extends Containerable> void updatePagingAndSorting( InterpretationContext context, ObjectPaging paging) throws QueryException { if (paging == null) { return; } RootHibernateQuery hibernateQuery = context.getHibernateQuery(); if (paging.getOffset() != null) { hibernateQuery.setFirstResult(paging.getOffset()); } if (paging.getMaxSize() != null) { hibernateQuery.setMaxResults(paging.getMaxSize()); } if (!paging.hasOrdering()) { return; } for (ObjectOrdering ordering : paging.getOrderingInstructions()) { addOrdering(context, ordering); } }