With deprecation of createCriteria() in Criteria class in Hibernate 5.2.2, many of its related functions can't be used anymore. I have found an alternative use for criteria.createAlias(String, String) and adding Restriction from the following link Deprecated createCriteria method in Hibernate 5 But I can't find how to substitute in JPA criteria the following functions available in Criteria:
criteria.setProjection(Projections.projectionList()
.add(Projections.distinct(Projections.property("student.id")), "id")
.add(Projections.property("student.name"), "name"));
criteria.addOrder(Order.asc("student.name"));
if (limit != null)
criteria.setMaxResults(limit);
if (offset != null)
criteria.setFirstResult(offset);
criteria.setResultTransformer(new AliasToBeanResultTransformer(Student.class));
Please provide me an alternative way to write the same code using JPA criteria API.