java - Spring autowire repository by entity type -


all of entities implement interface ientity.

i created interface repositories so:

@norepositorybean public interface irepository<t extends ientity> extends crudrepository<t, long> 

i have generic code takes in entity type , needs repository entity type. i'm trying use spring's applicationcontext.getbean(class<t>) method fetch appropriate repository entity passed in this:

@autowired applicationcontext context;  irepository<? extends ientity> getrepository(final ientity entity) {     class<irepository<? extends ientity>> clazz = ???????;     return context.getbean(clazz); } 

how tell class need autowire based on?


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -