Query by Boolean properties in spring-data-jpa without using method parameters

后端 未结 2 456
南笙
南笙 2020-12-28 11:16

Is it possible to query by Boolean properties in Spring Data JPA without using method parameters?

Basically I would like this to work without using custom @Query ann

相关标签:
2条回答
  • 2020-12-28 11:57

    The @Query anotation can even be skipped. So it should just work just like this:

    public Iterable<Entity> findByEnabledTrue();
    
    0 讨论(0)
  • 2020-12-28 12:22

    The JPA repository section query creation has the following methods.

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

    My guess would be to use

    @Query
    public Iterable<Entity> findByEnabledTrue();
    
    0 讨论(0)
提交回复
热议问题