use of com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO in project trainning by fernandotomasio.
the class HibernateTurmaDAO method findAllTurmasPlanejadas.
@Override
public List<TurmaPlanejadaDTO> findAllTurmasPlanejadas(Long planejamentoId, Long planoId, Long cursoId, Long responsavelId) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
Criteria criteria = session.createCriteria(TurmaPlanejada.class);
criteria.createAlias("itemPlanejamento", "item");
criteria.createAlias("curso", "c");
if (planejamentoId != null && planejamentoId > 0L) {
criteria.add(Restrictions.eq("item.planejamento.id", planejamentoId));
}
if (cursoId != null && cursoId > 0L) {
criteria.add(Restrictions.eq("curso.id", cursoId));
}
if (responsavelId != null && responsavelId > 0L) {
criteria.add(Restrictions.eq("responsavelId", responsavelId));
}
if (planoId != null && planoId > 0L) {
criteria.add(Restrictions.eq("c.plano.id", planoId));
}
criteria.addOrder(Order.asc("numeroTurma"));
@SuppressWarnings("unchecked") List<TurmaPlanejada> turmas = criteria.list();
List<TurmaPlanejadaDTO> dto = new ArrayList<TurmaPlanejadaDTO>();
for (TurmaPlanejada turma : turmas) {
dto.add(turma.createDTOWithoutDependencies());
}
return dto;
} catch (HibernateException e) {
Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("turmas.find.list.error"));
}
}
Aggregations