Reputation: 306
I want to create a method that will execute a query and return a Set of object of specific type. The type is given as param to method as follow:
Set<Person> people = Dao.executeQuery("select * from PERSON",Person.class);
In Dao class I would like to define the method as follow:
public static Set<???> executeQuery(String sql, ????){}
Can you please help me on how to write executeQuery method?
Upvotes: 2
Views: 90
Reputation: 7450
public static <T> Set<T> executeQuery(String sql, Class<T> klass) {
return null;
}
Upvotes: 6