We need to order by in subquery. Add new method orderBy for interface javax.persistence.criteria.Subquery