类型不匹配:推断类型是 KClass<GenderStatistics> 但 Class<TypeVariable(T)!>!预计
Type mismatch: inferred type is KClass<GenderStatistics> but Class<TypeVariable(T)!>! was expected
我正在尝试构建 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)
尝试改变
GenderStatistics::class
至
GenderStatistics::class.java
我正在尝试构建 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)
尝试改变
GenderStatistics::class
至
GenderStatistics::class.java