gpt4 book ai didi

java - 通过从存储库函数 jpa ,java 中排除多列(AND)中的特定值来进行过滤

转载 作者:行者123 更新时间:2023-11-30 01:44:03 24 4
gpt4 key购买 nike

我有一个包含记录的表。该表有年(int)和月(int)。我想过滤掉它们的组合并得到剩下的。

public List<T> findAllByYearAndMonthNot(int year,int month)

去上类或者需要

public List<T> findAllByYearNotAndMonthNot(int year,int month)

还是别的什么?

如果我将日期放入数据库表中。如果我使用

可以吗
public List<T> filterAllByDateBetweenNot(Date date1, Date Date2)

最佳答案

我会像这样使用 @Query 注释:

@Query("select i from Item i where not (i.year = ?1 and i.month = ?2)")
List<Item> findAllByNotYearAndMonth(int year, int month)

其中 Item 是具有年份和月份字段的数据库实体。

关于java - 通过从存储库函数 jpa ,java 中排除多列(AND)中的特定值来进行过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58836626/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com