在不使用方法参数的情况下,是否有可能在Spring Data JPA中通过布尔属性进行查询?
基本上,我希望这可以在不使用自定义@Query注释的情况下工作:
@Query("SELECT c FROM Entity c WHERE c.enabled = true")
public Iterable<Entity> findAllEnabled();
在不使用方法参数的情况下,是否有可能在Spring Data JPA中通过布尔属性进行查询?
基本上,我希望这可以在不使用自定义@Query注释的情况下工作:
@Query("SELECT c FROM Entity c WHERE c.enabled = true")
public Iterable<Entity> findAllEnabled();
JPA 存储库章节的查询创建具有以下方法。查看
True findByActiveTrue() … where x.active = true
False findByActiveFalse() … where x.active = false
我猜应该使用
@Query
public Iterable<Entity> findByEnabledTrue();
甚至可以省略@Query
注释,这样它应该像这样正常工作:
public Iterable<Entity> findByEnabledTrue();