I have a super class DBAdapter, it have method fetchAll() which selects all records from the table of the DB to List<DBObject>. I have inherit this class with CategoryDBAdapter, this class knows about class Category extended from DBObject.
When I call:
CategoryDBAdapter categoryDbAdapter = new CategoryDBAdapter(dbHelper);
List<Category> categories = categoryDbAdapter.fetchAll();
my code can’t cast List<DBObject> to the List<Category>. What is the common used way to resolve this collision?
You could change your DBAdapter and DBCategoryAdapter classes to use generics:
You would also need to adapt the content of the fetchAll() method, how easy this is depends on your implementation.