I'm using Spring CrudRepository
for database queries. How can I create a method signature (not writing SQL select statement myself) for a boolean property?
The following does not work:
class MyEntity {
private boolean active;
}
interface MyEntityRepository implements CrudRepository<MyEntity, Long> {
List<MyEntity> findActive(); //or also: findNotActive();
}
I would do:
Then the service layer would be
UPDATE
As pointed out by @OliverGierke you could simplify your repository even more by doing:
For all the supported keywords you should see the section
of the reference documentation