Search in sources :

Example 6 with ItemPlanejamento

use of com.tomasio.projects.trainning.model.ItemPlanejamento in project trainning by fernandotomasio.

the class HibernateItemPlanejamentoDAO method findAll.

@Override
public List<ItemPlanejamentoDTO> findAll(Long planejamentoId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        @SuppressWarnings("unchecked") List<ItemPlanejamento> items = session.createQuery("from ItemPlanejamento item " + " where item.planejamento.id=:param order by item.curso.codigo").setLong("param", planejamentoId).list();
        List<ItemPlanejamentoDTO> dto = new ArrayList<ItemPlanejamentoDTO>();
        for (ItemPlanejamento item : items) {
            ItemPlanejamentoDTO itemDTO = item.createDTOWithoutDependencies();
            dto.add(itemDTO);
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateItemPlanejamentoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("planejamento.itens.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ItemPlanejamentoDTO(com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO) HibernateException(org.hibernate.HibernateException) ArrayList(java.util.ArrayList) ItemPlanejamento(com.tomasio.projects.trainning.model.ItemPlanejamento) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)6 ItemPlanejamento (com.tomasio.projects.trainning.model.ItemPlanejamento)6 HibernateException (org.hibernate.HibernateException)5 Session (org.hibernate.Session)5 ItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO)2 ArrayList (java.util.ArrayList)2 Curso (com.tomasio.projects.trainning.model.Curso)1 Fase (com.tomasio.projects.trainning.model.Fase)1 Organizacao (com.tomasio.projects.trainning.model.Organizacao)1 Planejamento (com.tomasio.projects.trainning.model.Planejamento)1 TurmaPlanejada (com.tomasio.projects.trainning.model.TurmaPlanejada)1 HashSet (java.util.HashSet)1