April 05
Prof. Ismael H. F. Santos -  ismael@tecgraf.puc-rio.br                                                          2
DAO Example – The need for IoC
nDatabase access through Hibernate
n  public class UserDaoImpl extends HibernateDaoSupport
n                         implements UserDao {
n    public User getUserById( Integer id ) {
n      HibernateTemplate hib = getHibernateTemplate();
n      return (User)hib.get(User.class, id);
n    }
n    ... ...
n  }
nUsed in more than twenty controllers, validators, and access decision voters
nAdd instructor/student to class sections
nValidate whether a username is already used
nCheck whether a user can access certain assignment or grade
n ...
The DAO would be injected with a Session/Connection object