I am trying to implement a method using a composable repository in micronaut.
I have:
@Repository
public interface EmployeeRepository extends CrudRepository<Employee, Long>, EmployeeRepositoryCustom {
}
Here, the EmployeeRepositoryCustom is an interface with the method 'list()':
public interface EmployeeRepositoryCustom {
List<Employee> list();
}
Then I have EmployeeRepositoryCustomImpl class that implements the methods of the interface:
public class EmployeeRepositoryCustomImpl implements EmployeeRepositoryCustom {
@PersistenceContext
EntityManager em;
@Override
@Transactional
public List<Employee> list() {
// implementation code
}
}
When I call the method using:
@Inject
EmployeeRepository employeeRepository;
public List<Employee> get(){
return employeeRepository.list();
}
I get the following message:
java.lang.IllegalStateException: Micronaut Data method is missing compilation time query information. Ensure that the Micronaut Data annotation processors are declared in your build and try again with a clean re-build.
I've tried adding the annotation @Repository on EmployeeRepositoryCustom and EmployeeRepositoryCustomImpl, but it still gives the same error message. Is there any way to get this done?
I know I can just inject the EmployeeRepositoryCustom class and access the method, but I want to do it using the composable repository method. Because, the employee repository comes from another schema (not the default datasource but another datasource) and I would like to be able to specify the schema like:
@Repository("schema2")