I am trying to write a query using SpringData Jpa using the @Query annotation on the interface method declaration.
The interface looks like this:
public interface MyService {
@Query("select * from employee e where e.projectId = ?1")
public List<Employee> getEmployeesWorkingOnAProject(String projectId) throws MyException;
}
I also have a class that implements this interface:
@Component
public class ProjectServiceImpl implements ProjectService {
}
I am not sure how will this query execution work and how to provide an implementation for getEmployeesWorkingOnAProject method in the imeplementing class.
Thanks
@Query. Just name your methodfindByProjectId(String), or evenfindByProject(Project)if you have a foreign-key relationship.