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