java 带参数的JPA传递列表

plupiseo  于 2023-04-19  发布在  Java
关注(0)|答案(1)|浏览(136)

我的工作是从一个多次访问存储库的流中重构一些代码,简单地将整个对象列表传递给存储库,然后返回所有行。我有三个参数,我想在数据库中搜索,然后从数据库中返回整行。下面是我目前的设置:

@Query(nativeQuery = true, value = "SELECT * FROM PEOPLE as p WHERE p.id IN :personSearchParams AND s.firstName IN :personSearchParams AND s.lastName IN :personSearchParams")
    fun findByIdAndFirstNameAndLastName(@Param("personSearchParams") personSearchParams: List<PersonSearchParams>): List<Person>

我的数据对象是:

data class personSearchParam (

    @NotBlank(message = "id must not be blank.")
    var id: String,

    @NotBlank(message = "firstName must not be blank.")
    var firstName: String,

    @NotBlank(message = "lastName must not be blank.")
    var lastName: String
)

但我收到以下错误:Could not determine a type for class: com.person.entity.personSearchParam
我如何能够传递参数列表并期望返回实体列表?

3okqufwl

3okqufwl1#

尝试将personSearchParam更改为PersonSearchParam,并将@NotBlank更改为@field:NotBlank。参考=https://kotlinlang.org/docs/annotations.html#annotation-use-site-targets

相关问题