类型不匹配:推断的类型为KClass <GenderStatistics>,但类为<TypeVariableT!>!被期待

问题描述

我正在尝试构建Query Projection,但遇到以下错误消息:

Type mismatch: inferred type is KClass<GenderStatistics> but Class<TypeVariable(T)!>! was expected

引起问题的代码:

  fun status(): String {
    val query = accRepo.find("""
      select g.abbr as abbr,g.description as description,count(p) as quantity
        from Account a
        inner join a.gender as g
        group by g.abbr,g.description
      """.trimIndent())
        .project(GenderStatistics::class)

方法project的类型为Class<TypeVariable(T)!>!,但是我传递了错误的类型。如何在Kotlin中传递正确的类型?在Java中,它将为GenderStatistics.class

GenderStatistics定义为:

@RegisterForReflection
class GenderStatistics(val abbr: String,val description: String,val quantity: Int)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)