Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个方法来执行查询并返回一组特定类型的对象。类型作为参数提供给方法,如下所示:
Set<Person> people = Dao.executeQuery("select * from PERSON",Person.class);
在 Dao 类中,我想定义方法如下:
public static Set<???> executeQuery(String sql, ????){}
你能帮我写一下executeQuery方法吗?
public static <T> Set<T> executeQuery(String sql, Class<T> klass) { return null; }
public static <T> Set<T> executeQuery( String sql, Class<T> type );