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;
}
}