尝试重写函数时Kotlin Spring存储库继承问题

尝试重写函数时Kotlin Spring存储库继承问题,kotlin,spring-data-jpa,spring-data,spring-data-solr,Kotlin,Spring Data Jpa,Spring Data,Spring Data Solr,为了清晰起见,我会尽量简化。 这是我的Entities.kt,我只有两个类,A和B。B扩展了A @SolrDocument(solrCoreName = "core") open class A( @Id @Indexed(name="id", type = "string_or") var id: String = "", @Indexed(name="type"

为了清晰起见,我会尽量简化。 这是我的Entities.kt,我只有两个类,A和B。B扩展了A

@SolrDocument(solrCoreName = "core")
open class A(
    @Id
    @Indexed(name="id", type = "string_or")
    var id: String = "",

    @Indexed(name="type", type = "string"
    var type: String = ""
)
open class B(
  @Indexed(name="b_field", type= "string")
  var bField: String = ""
) : A()
在my Repositories.kt中,我尝试复制此继承模型,然后尝试重写存储库B的findAll函数,以便只返回类型B的对象,如下所示:

interface BaseRepository<T: A>: SolrCrudRepository<T, String> {
    fun findByType(type: String): List<T>
}

interface ARepository: BaseRepository<A> {

}

interface BRepository: BaseRepository<B> {
   @Query("type:B")
   override fun findAll(): List<B>
}
我也尝试过使用JPA而不是Solr来做类似的事情,但我有同样的问题,父(默认)findAll函数被执行,而不是被重写的函数。有什么想法吗

@RestController
@RequestMapping("/api/B")
class BController(private val repository: BRepository) {

  @GetMapping("")
  fun findAll() = repository.findAll()
}