Spring JPA 如何进行无参数查询布尔类型

72 阅读1分钟

根据官方的文档说明:Spring Data JPA - Reference Documentation

2022-10-10_12-40-27

可以在查询的参数后面添加 True 或 False 来进行查询。

例如,如果需要对下面的参数进行查询:

True    findByActiveTrue()  … where x.active = true
False   findByActiveFalse() … where x.active = false

那么我们在查询的接口上可以使用:

@Query
public Iterable<Entity> findByEnabledTrue();

来完成查询。

www.ossez.com/t/spring-jp…