Here are the details:
I have multiple Models in my application, each model has a repository that extends Spring's CrudRepository.
For example:
EyeColorModelhas repositoryinterface EyeColorRepository extends CrudRepository<EyeColor, Long>HairColorModelhas repositoryinterface HairColorRepository extends CrudRepository<HairColor, Long>StateModelhas repositoryinterface StateRepository extends CrudRepository<State, Long>and so on ...
I would like to create a generic MyApplicationRepository that extends all of my individual repositories so that I need only create a single instance of MyApplicationRepository instead of creating multiple instances of my individual repositories.
I tried this:
public interface MyApplicationRepositoryInterface extends
EyeColorRepository,
HairColorRepository,
StateRepository {
}
public class MyApplicationRepository implements MyApplicationRepositoryInterface {
}
However, when I try to extend all of my individual repositories in MyApplicationRepositoryInterface I get this error:
CrudRepository cannot be inherited with different arguments: <com.myapp.Models.EyeColor, java.lang.Long> and <com.myapp.Models.HairColor, java.lang.Long>
So is there a way to do what I would like to do, or am I stuck with instantiating instances of all my model repositories?