且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查其他两个日期之间的日期 spring 数据 jpa

更新时间:2023-11-29 12:37:16

你应该看看 参考文档.解释的很好.

You should take a look the reference documentation. It's well explained.

在你的情况下,我认为你不能使用 between 因为你需要传递两个参数

In your case, I think you cannot use between because you need to pass two parameters

Between - findByStartDateBetween ... 其中 x.startDate 介于 ?1 和 ?2 之间

Between - findByStartDateBetween … where x.startDate between ?1 and ?2

在您的情况下,请考虑使用 LessThanLessThanEqualGreaterThanGreaterThanEqual

In your case take a look to use a combination of LessThan or LessThanEqual with GreaterThan or GreaterThanEqual

  • 小于/小于等于

LessThan - findByEndLessThan ... 其中 x.start1

LessThan - findByEndLessThan … where x.start< ?1

LessThanEqual findByEndLessThanEqual ... where x.start

LessThanEqual findByEndLessThanEqual … where x.start <= ?1

  • GreaterThan/GreaterThanEqual
  • GreaterThan - findByStartGreaterThan ... where x.end>?1

    GreaterThan - findByStartGreaterThan … where x.end> ?1

    GreaterThanEqual - findByStartGreaterThanEqual ... where x.end>= ?1

    GreaterThanEqual - findByStartGreaterThanEqual … where x.end>= ?1

    您可以使用运算符 AndOr 将两者结合起来.

    You can use the operator And and Or to combine both.