【问题标题】:How to fix groovy.lang.MissingMethodException: No signature of method when calculating the total如何修复 groovy.lang.MissingMethodException:计算总数时没有方法签名
【发布时间】:2019-01-08 18:15:09
【问题描述】:

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

groovy.lang.MissingMethodException:没有方法签名:项目 .sampleTest.column() 适用于参数类型:(java.lang.String) 值:[数量] 可能的解决方案: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();

【问题讨论】:

    标签: grails cassandra


    【解决方案1】:

    要在fcall() 中使用列名,您需要使用静态方法QueryBuilder.column()。所以当你在fcall() 中使用它时,你需要这样称呼它:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2017-06-19
      相关资源
      最近更新 更多