按属于加入的字段排序效果很好:
CriteriaBuilder builder = em.getCriteriaBuilder();
Root root = criteria.from(Employee.class);
Join joinPerson = root.join("person");
criteria.orderBy(builder.asc(joinPerson.get("lastName")));
如何通过获取:
来解决类似问题CriteriaBuilder builder = em.getCriteriaBuilder();
Root root = criteria.from(Employee.class);
Fetch fetchPerson = root.fetch("person");
criteria.orderBy(builder.asc(fetchPerson.????));
答案 0 :(得分:1)
将您的抓取功能转换为路径,例如:
Path fetchAsPath = (Path) root.fetch("person");
fetchAsPath.get("lastName");