是否可以不使用方法参数在 Spring Data JPA 中通过 boolean 属性进行查询?
基本上我希望它在不使用自定义 @Query 注释的情况下工作:
@Query("SELECT c FROM Entity c WHERE c.enabled = true")
public Iterable<Entity> findAllEnabled();
最佳答案
JPA repository section查询创建有以下方法。
True findByActiveTrue() … where x.active = true
False findByActiveFalse() … where x.active = false
我的猜测是使用
@Query
public Iterable<Entity> findByEnabledTrue();
关于java - 在 spring-data-jpa 中通过 boolean 属性查询而不使用方法参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17600790/