jpa2 CriteriaBuilder order by “ORDER BY expressions must appear in select list”
问题 I'm writing a query with CriteriaBuilder , but it has not been possible to add the order by clause, because an error it's thrown with the message ORDER BY expressions must appear in select list this are my entities. public class A{ Integer aId; @ManyToOne @JoinColumn(name = "bId", nullable = false) B classB; //setter and getter. } public class B{ Integer bId; String name; //setter and getter. } my query look like this. CriteriaBuilder cb = super.getEntityManager().getCriteriaBuilder();