1
resposta

Herança e a DAO

Teria um exemplo da DAO usando a herança?

1 resposta

Oi Herbert,

Usando herança é bem comum ver algo assim:

public interface BaseDao<EntityType extends Object>
{
   public Serializable save(EntityType entity) throws DataAccessException,
        HibernateException;

   public void merge(EntityType entity) throws DataAccessException,
        HibernateException;

   public void flush() throws DataAccessException,HibernateException;
}
@Repository
public abstract class BaseDaoImpl<EntityType extends Object> implements BaseDao<EntityType>{
 // Implementation for baseDao methods 
}
 @Repository
public class EmpDaoImpl extends BaseDaoImpl<Employee> implements EmpDao{
 // Implementation
}