java按计数排序HQL
我试图根据Student
的数量对School
进行排序。它们之间存在ManyToOne
/OneToMany
关系
这不起作用,但这是我到目前为止所做的
from School s order by count(s.students)
我宁愿不使用标准,因为我必须重构很多代码。有没有办法通过HQL
实现这一点
你可以在下面搜索框中键入要查询的问题!
我试图根据Student
的数量对School
进行排序。它们之间存在ManyToOne
/OneToMany
关系
这不起作用,但这是我到目前为止所做的
from School s order by count(s.students)
我宁愿不使用标准,因为我必须重构很多代码。有没有办法通过HQL
实现这一点
# 1 楼答案
好吧,我知道了。这奏效了
from School s order by size(s.students)
根据Hibernate文档