I have the following line of code for ORMLITE to create a dao (Data access object). I am trying to avoid repeating myself for ALL entities by writing the same statement for different database tables/entities.
Dao<Entity, String> entityDao = DaoManager.createDao(connectionSource,Entity.class);
How can i create a method which accepts ANY Entity that i have and return the correct entityDao object.
Such that I can combine the logic
Dao<UserEntity, String> userEntityDao = DaoManager.createDao(connectionSource,UserEntity.class);
and
Dao<AccountEntity, String> accountEntityDao = DaoManager.createDao(connectionSource,AccountEntity.class);
I have tried the following method:
private Dao<?, String> createDAO(Class<?> dataClass) throws SQLException{
// instantiate the dao
return DaoManager.createDao(connectionSource, dataClass);
}