使用这样的HQL查询:
def accounts = Account.executeQuery("select distinct a.number from Account a")
def accountSize = accounts.size()
这给出了accountSize,但是问题是,也将从Hibernate中获取帐户。是否有一个命令可以计算查询结果的大小而无需获取结果?
最佳答案
Account.count()
可以为您提供Account
表的总行数。
那是你需要的吗?
如果您需要HQL,则
def accountSize = Account.executeQuery("select count(distinct a.number) from Account a")
关于hibernate - 如何计算 hibernate 结果而不在Grails中获取它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17308736/