如何修复groovy.lang.MissingMethodException:计算总数时没有方法签名

How to fix groovy.lang.MissingMethodException: No signature of method when calculating the total

我正在尝试连接到 Cassandra 并在 Grails 中编写一个查询来计算总金额,但我遇到了一个缺少方法的异常:

groovy.lang.MissingMethodException: No signature of method: project .sampleTest.column() is applicable for argument types: (java.lang.String) values: [amount] Possible solutions: collect(), dump(), collect(groovy.lang.Closure)

下面是我写的求和金额的查询。

Select selectQuery = QueryBuilder.select().fcall("sum", column("amount")).from(tableName).allowFiltering()

Session session = cassandraTemplate.getSession();

Where selectWhere = selectQuery.where();

fcall() you need to use the static method QueryBuilder.column() 中使用列名。所以当你在 fcall() 中使用它时,你需要像这样调用它:

Select selectQuery = QueryBuilder.select().fcall("sum", QueryBuilder.column("amount")).from(tableName).allowFiltering()