如何从SQLite创建通用DAO管理器?(传递模板参数)

时间:2016-09-23 12:41:50

标签: java sqlite generics parameter-passing repository-pattern

我有以下课程:

public class CategoryRepository<T> implements IRepository<T> {
    String databaseUrl = "jdbc:sqlite://D://ForumDatabase10.db";
    JdbcConnectionSource connectionSource = new JdbcConnectionSource(
            databaseUrl);
    Dao<T, String> genericDAO = DaoManager.createDao(
            connectionSource,T);
    @Override
    public T get(String id) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Set<T> getAll() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void persist(T entity) {
        genericDAO.create(entity);      
    }

    @Override
    public void remove(T entity) {
        // TODO Auto-generated method stub

    }

问题是我在此行收到编译错误

 Dao<T, String> genericDAO = DaoManager.createDao(
            connectionSource,T);

我想在createDAO方法中传递泛型作为参数,但我不知道如何。 有人可以帮帮我吗?

0 个答案:

没有答案