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