我正在尝试构建查询投影,但遇到以下错误消息:
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)