Create better Base DAO class I created a DAO class which is base class for all other DAO classes. 

I use Spring Framework 4 and Hibernate 4.

Question: Is there anything that could be done better? 

public class GenericDaoImpl&lt;E, I extends Serializable&gt; implements GenericDao&lt;E, I&gt; {
    private Class&lt;E&gt; entityClass;

    @Autowired
    private SessionFactory sessionFactory;

    public GenericDaoImpl(Class&lt;E&gt; entityClass) {
        this.entityClass = entityClass;
    }

    @Override
    public Session getCurrentSession() {
        return sessionFactory.getCurrentSession();
    }

    @Override
    @SuppressWarnings("unchecked")
    public List&lt;E&gt; findAll() throws DataAccessException {
        return getCurrentSession().createCriteria(entityClass).list();
    }

    @Override
    @SuppressWarnings("unchecked")
    public E find(I id) {
        return (E) getCurrentSession().get(entityClass, id);
    }

    @Override
    public void create(E e) {
        getCurrentSession().save(e);
    }

    @Override
    public void update(E e)  {
        getCurrentSession().update(e);
    }

    @Override
    public void delete(E e) {
        getCurrentSession().delete(e);
    }

    @Override
    public void flush() {
        getCurrentSession().flush();
    }
}


Sample DAO class which extends base DAO class is for example this one:

@Repository("articleDao")
public class ArticleDaoImpl extends GenericDaoImpl&lt;ArticleEntity, Long&gt; implements ArticleDao {
    public ArticleDaoImpl(){
        super(ArticleEntity.class);
    }
}
To be able to create a parameter-less constructor add the following code into your constructor. It will use reflection to set entityClass. This way you don't even need to worry about passing in a class type, you can extend out your generic DAO and its type will be set by parameterisation.

public GenericDaoImpl() {
    Type e = getClass().getGenericSuperclass();
    ParameterizedType pt = (ParameterizedType) e;
    entityClass = (Class&lt;E&gt;) pt.getActualTypeArguments()[0];
}


This removes the need for having constructors in subclasses of your GenericDAOImpl.

Why don't you combine your create and update methods? It makes for easier service calls.

@Override
public void saveOrUpdate(E e){
    getCurrentSession().saveOrUpdate(e);
}


Hibernate will automatically make the determination whether a save or update call is appropriate. If your ID field is set, then perform an update, otherwise perform a save.

Also, I would remove getCurrentSession() from your interface and change the method to private. You shouldn't be accessing the Hibernate session from anywhere outside the DAO so there is no reason to expose out your getCurrentSession() method.