Spring JPA findBy 两个或条件
Spring JPA findBy two or conditions
需要有关 Spring JPA 的帮助。假设我想知道谁在收到交通罚单时检查了汽车。这样 licenseNum
和
citationDate
大于checkoutDate
且citationDate
小于returnDate
;或
citationDate
大于 checkoutDate
而 returnDate
是 null
。
目前,
List<SomeEntity> findByLicenseNumAndCheckOutDatetimeBeforeAndReturnDatetimeAfterOrReturnDatetimeIsNullOrderByIdDesc()
正确生成 #1 但生成所有 licenseNum
和 returnDate
null
.
如何用 'or' 语句正确编写 spring JPA 语句?
您实际上可以考虑使用 Query
注释,您可以在其中指定自定义查询。 Yon可以选择一个更有意义的方法名并且方便maintain/change.
需要有关 Spring JPA 的帮助。假设我想知道谁在收到交通罚单时检查了汽车。这样 licenseNum
和
citationDate
大于checkoutDate
且citationDate
小于returnDate
;或citationDate
大于checkoutDate
而returnDate
是null
。
目前,
List<SomeEntity> findByLicenseNumAndCheckOutDatetimeBeforeAndReturnDatetimeAfterOrReturnDatetimeIsNullOrderByIdDesc()
正确生成 #1 但生成所有 licenseNum
和 returnDate
null
.
如何用 'or' 语句正确编写 spring JPA 语句?
您实际上可以考虑使用 Query
注释,您可以在其中指定自定义查询。 Yon可以选择一个更有意义的方法名并且方便maintain/change.