public class JobAssetService extends GenericService<JobAssetService, JobAsset, JobAssetDao> {
}
我想为我的服务层提供通用的save()功能,但它似乎不喜欢我传递给dao.save()
的东西。这似乎是这应该工作...无法调用通用类内的实体保存
不兼容的类型 要求:M 发现:java.lang.Object继承
public class GenericService<T, M, Dao extends GenericDao> {
protected Dao dao;
protected EntityManager em;
public GenericService() {
}
//map the dao/entity manager when instantiated
public GenericService(Class<Dao> daoClass) {
//map entity manager & dao
//code removed for readability
}
public M save(M entity) {
EntityTransaction tx = em.getTransaction();
tx.begin();
entity = dao.save(entity); //IntelliJ complains about this
tx.commit();
return entity;
}
}
什么是'dao.save'? – SLaks 2013-02-18 21:45:56
Dao/GenericDao的代码是什么? – mantrid 2013-02-18 21:46:12