I am using Spring boot 2 with Reactive repository for executing stored proc which will return the count. I have 30 stored proc and all of them will just return a number and takes no arguments.
So created a model for stored proc StroedProcDomain.java and one sample repository as below.
@Repository
public interface JobRepository extends ReactiveCrudRepository<StroedProcDomain, Long> {
@Query("CALL JOB_LOAD()")
Mono<Integer> executeProc();
}
Need to create 30 such repositories and would like to enforce all the repositories to use the same method
Mono<Integer> executeProc()
But the stored proc name will be different. So @Query will be different for each repository.
What is the best way to achieve this?
Currently, I have 30 repositories. Would like to have a base repository so as to force the method name.
In theory you could put a two methods on a common interface: your actual query method, which would be implemented by a custom method calling the stored procedure, plus a method that provides just the name of the stored procedure.
But this would be considerable more code and more complex code than just an annotated query method on each repository.