'Spring Data JPA - Derived Count Query without filtering

I am trying the methods I've found at: https://www.logicbig.com/tutorials/spring-framework/spring-data/derived-count-query.html

I'm trying to learn about what can count do. Those seems to work fine where there are no relationships and I managed to go them. In those examples, al the required fields are on the same entity.

Example: I have a MEETINGS table with two (N:1) relationships ManyToOne from two fields (employeesAttended, employeesNotAttending).

I want to count, from the meetings repository and using JPA the number of employees that attended a particular meeting.

I've tried:

This works just fine (counting employees from a particular department):

long countFindByemployeesAttended_departmentContainingIgnoreCase(String department);

This doesn't work:

long countFindByemployeesAttended();
long countFindByemployeesAttended_id();
long countFindByemployeesAttended_department();

What I am understanding wrong here? Thanks for your help in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source