* {@inheritDoc}
*/
public void prepare(final int startIndex, final int endIndex,
final List<SortConstraint> sortConstraints)
{
final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
final CriteriaQuery<E> criteria = builder.createQuery(entityType);
final Root<E> root = criteria.from(entityType);
applyAdditionalConstraints(criteria.select(root), root, builder);
for (final SortConstraint constraint : sortConstraints)
{
final String propertyName = constraint.getPropertyModel().getPropertyName();
final Path<Object> propertyPath = root.get(propertyName);
switch (constraint.getColumnSort())
{
case ASCENDING:
criteria.orderBy(builder.asc(propertyPath));
break;
case DESCENDING:
criteria.orderBy(builder.desc(propertyPath));
break;
default:
}
}