CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<GradedEvent> cq = cb.createQuery(GradedEvent.class);
Root<GradedEvent> gradedEventRoot = cq.from(GradedEvent.class);
cq.where(cb.and(cb.equal(gradedEventRoot.get("course"), course),
cb.equal(gradedEventRoot.get("term"), term)));
cq.orderBy(cb.asc(gradedEventRoot.get("assignment")),
cb.asc(gradedEventRoot.get("version")));
TypedQuery<GradedEvent> gradedEventQuery = em.createQuery(cq);
// Run the query and return the resulting list of Graded Events
return gradedEventQuery.getResultList();