随着 Hibernate 5.2.2 中 Criteria 类中的 createCriteria() 的弃用,它的许多相关函数都不能再使用了。我找到了 criteria.createAlias(String, String) 的替代用途,并从以下链接添加了 Restriction Deprecated createCriteria method in Hibernate 5 但我找不到如何在 JPA 标准中替换 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));
请为我提供另一种使用 JPA 标准 API 编写相同代码的方法。