0
這是我的第一個問題。我是初學者:-)泛型錯誤 - 找不到符號類
我有通用的DAO(CrudDao
):
public class CrudDAO<T> {
@PersistenceContext
protected EntityManager em;
private Class<T> classePersistencia;
public CrudDAO() {
this.setClassePersistencia((Class<T>) ((ParameterizedType)
getClass().getGenericSuperclass()).getActualTypeArguments()[0]);
}
public T salvar(T entity) {
em.persist(entity);
return entity;
}
public T alterar(T entity) {
return em.merge(entity);
}
public void excluir(T entity) {
em.remove(entity);
}
public T buscarPorId(Long id) {
return (T) em.find(getClassePersistencia(), id);
}
public List<T> buscarTodos(){
return em.createQuery("from " + getClassePersistencia().getName()).getResultList();
}
/*Getter e Setter*/
public Class<T> getClassePersistencia() {
return classePersistencia;
}
public void setClassePersistencia(Class<T> classePersistencia) {
this.classePersistencia = classePersistencia;
}
}
,我有DiasService
public class DiasService extends CrudDAO<Dias> implements IdiasService {
@Transactional(readOnly = true)
public Dias buscaPorId(Long id) {
return (Dias) super.buscarPorId(id);
}
@Transactional(readOnly = false)
public Dias salvar(Dias dia) {
return (Dias) super.salvar(dia);
}
@Transactional(readOnly = false)
public Dias alterar(Dias dia) {
return (Dias) super.alterar(dia);
}
@Transactional(readOnly = false)
public void excluir(Dias dia) {
super.excluir(dia);
}
@Transactional(readOnly = true)
public List<Dias> buscaPorPeriodo(Date inicio, Date fim) {
return null;
}
@Transactional(readOnly = false)
public List<Dias> buscaTodos() {
return super.buscarTodos();
}
@Transactional(readOnly = true)
public Dias buscaPorData(Date data) {
return null;
}
}
當我做編譯,我得到錯誤:
cannot find symbol class CrudDAO
怎麼了?
完成!我重新開始我的IntelliJ和它沒關係;-)謝謝! – user812612 2013-05-04 21:21:59