【问题标题】:Spring Boot Data JPA method for two columns with one entity具有一个实体的两列的 Spring Boot Data JPA 方法
【发布时间】:2021-02-25 04:40:38
【问题描述】:

我尝试找到一种 Spring Data JPA 方法,该方法可以从两列中找到一组数据。

我的意思是我有一张桌子,我想在两个where in 子句中使用相同的集合。

现在,我使用那个方法:findAllByCallerInOrCalleeIn(Set<String> callerPhones, Set<String> calleePhones, Pageable pageable); callerPhonescalleePhones 完全一样。

我尝试了下面的方法名称,但都失败了:

findAllByCallerInOrCalleeIn(Set<String> phones, Pageable pageable)
findAllByCallerInAndCalleeIn(Set<String> phones, Pageable pageable)
findAllByCallerOrCalleeIn(Set<String> phones, Pageable pageable)
findAllByCallerAndCalleeIn(Set<String> phones, Pageable pageable)

你能给我一个建议吗?

【问题讨论】:

    标签: spring spring-boot spring-data-jpa


    【解决方案1】:

    您可以尝试使用@Query 或两次输入相同的参数, 见this答案

    【讨论】:

    • 我知道@Query,但我尝试编写 JPA 方法。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-17
    • 2018-12-27
    • 2021-05-21
    • 2014-12-06
    • 2020-02-02
    • 1970-01-01
    相关资源
    最近更新 更多