title: DAO vs ORM(hibernate) pattern
body: <p>i read in some articles DAO is not mandatory with hibernate and its implementation is by "it depends", in other words, we can choose between ORM vs DAO pattern.</p>
  
  <p>Ok, let's assume that i don't want use a DAO pattern, so im using only session CRUD and query operation provided by hibernate(my ORM).</p>
  
  <p>Especially for the "search" and "find" queries is not correct to rewrite them always, so is reasonable think to put them into a class.</p>
  
  <p>But then this class is a simple DAO without all implementation of DAO pattern and DAOFactory, only a lightweight implementation of a DAO.
  So, the point is that we need alway a DAO and the choice is heavy DAO implementation vs lightweight DAO implementation?</p>
  
  <p>What i said is wrong?</p>
  
  <p><strong>EDIT</strong>
  Another problem i have is where put dao interactions, for example i have to login an User and write a Log of the login (useless example i know...)</p>
  
  <p>So in a DAO pattern i have all generic dao implementations, a DAOFactory and finally UserHibernateDAO and LogHibernateDAO.
  The login operation is a <strong>business method</strong>:</p>
  
  <pre><code>private void login(String username, String password){
      daoFactory.beginTransaction();
      UserDAO userDao=daoFactory.HIBERNATE.getUserDao();
      LogDAO logDao=daoFactory.HIBERNATE.getLogDao();
      if(userDao.checkAccount(username, password){
          User user=userDao.findByAccount(username, password);
          logDao.save(new Log("log-in", user);
      }
      daoFactory.commit();
  }
  </code></pre>
  
  <p>Is this reasonable? Can i use dao in this way?
  If i want handle exception, the better place to do it is ina a business logic?</p>
  
  <p><strong>EDIT2</strong>
  Let's assume to use a DAO pattern, the main reason to do it is to be able to switch between tecnhology(ORM->JDBC etc..), it all fine and ok, BUT where can i handle hibernate session and transaction?
  I can't put it into a DAO, it's anty pattern, and i can't put it into a service layer, becouse in a hipohtetycal switch i have to remove all this transaction(becouse other tecnhology may not use them).</p>