Search in sources :

Example 6 with CurriculoMinimo

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

the class HibernateCurriculoMinimoDAO method findAllCurosWithCurriculosMinimos.

@Override
public List<Curso> findAllCurosWithCurriculosMinimos() throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    List<Curso> result = new ArrayList<Curso>();
    try {
        @SuppressWarnings("unchecked") List<CurriculoMinimo> curriculos = session.createQuery("from CurriculoMinimo c where c.curso != null ").list();
        Set<Curso> cursosSet = new HashSet<Curso>();
        for (CurriculoMinimo curriculoMinimo : curriculos) {
            cursosSet.add(curriculoMinimo.getCurso());
        }
        for (Curso curso : cursosSet) {
            result.add(curso);
        }
        return result;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("cursos.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) ArrayList(java.util.ArrayList) CurriculoMinimo(com.tomasio.projects.trainning.model.CurriculoMinimo) Curso(com.tomasio.projects.trainning.model.Curso) Session(org.hibernate.Session) HashSet(java.util.HashSet)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)6 CurriculoMinimo (com.tomasio.projects.trainning.model.CurriculoMinimo)6 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 Transactional (org.springframework.transaction.annotation.Transactional)4 HibernateException (org.hibernate.HibernateException)2 Session (org.hibernate.Session)2 CurriculoMinimoDTO (com.tomasio.projects.trainning.dto.CurriculoMinimoDTO)1 Curso (com.tomasio.projects.trainning.model.Curso)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1