Reputation: 347
I'm trying to test my application , the problem is that i have a repository interface which contains some methods like this:
public interface EmployeeDetailRepository extends JpaRepository<EmployeeDetail, Integer> {
public List<EmployeeDetail> employeeTasks(@Param("emp_id") List<Integer> emp_id, @Param("flag") boolean Active);
}
The query for this method is defined as a named-native-query in another xml file. When i start any test , i have a fail to load ApplicationContext with this error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeDetailRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException
: No property employeeTasks found for type EmployeeDetail!
This error is shown only when i start the test cases , when i start the application, nothing happened. Any help will be much appreciated
Upvotes: 1
Views: 336
Reputation: 84
I think that you are trying to get the list of active employees in the tables and here is the query for you.
But the below explanation is for only one employee Id. But if you want to find out the list of the employees when you have given the list of Employee Id's I thikn you have to implement the method yourself.
public interface EmployeeDetailRepository extends JpaRepository<EmployeeDetail, Integer> {
@Query("select e from EmployeeDetail e where emp_id=?1 and active=?2")
public List<EmployeeDetail> employeeTasks(Integer emp_id, boolean active);
}
However if you want the exact operation you have asked in your question you would have to implement the same. You may find how to do a custom implementation on this page
Thanks, Abhijeet.
Upvotes: 1
Reputation:
Clearly you go something wrong with your configuration because spring is trying to interpret method name. Maybe you could annotate your EmployeeDetail with @NamedQuery. This worked well in my case. It is well described here.
Upvotes: 1