0

Using a HQL query like this:

def accounts = Account.executeQuery("select distinct a.number from Account a") 
def accountSize = accounts.size()

This gives the accountSize but the problem is that the accounts will be fetched from Hibernate as well. Is there a command that allows to compute the size of the query result without fetching the result?

4

1 回答 1

3

Account.count()Account可以给你表格的总行数。

那是你需要的吗?

如果您需要 HQL,那么

def accountSize = Account.executeQuery("select count(distinct a.number) from Account a")
于 2013-06-25T22:41:06.760 回答