Search in sources :

Example 16 with AnotacaoDTO

use of com.tomasio.projects.trainning.dto.AnotacaoDTO in project trainning by fernandotomasio.

the class HibernateAnotacaoDAO method findAllByObjectId.

@Override
public List<AnotacaoDTO> findAllByObjectId(String user, String objectId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        @SuppressWarnings("unchecked") List<Anotacao> anotacoes = session.createQuery("from Anotacao anotacao" + " where anotacao.user=:user" + " and anotacao.objectId=:object order by anotacao.dataCriacao desc").setString("object", objectId).setString("user", user).list();
        List<AnotacaoDTO> dto = new ArrayList<AnotacaoDTO>();
        for (Anotacao anotacao : anotacoes) {
            dto.add(anotacao.createDTO());
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateAnotacaoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("anotacoes.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Anotacao(com.tomasio.projects.trainning.model.Anotacao) AnotacaoDTO(com.tomasio.projects.trainning.dto.AnotacaoDTO) ArrayList(java.util.ArrayList) Session(org.hibernate.Session)

Aggregations

AnotacaoDTO (com.tomasio.projects.trainning.dto.AnotacaoDTO)16 DAOException (com.tomasio.projects.trainning.exception.DAOException)9 AnotacaoDAO (com.tomasio.projects.trainning.dao.AnotacaoDAO)6 ArrayList (java.util.ArrayList)5 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Transactional (org.springframework.transaction.annotation.Transactional)4 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)3 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)3 FolhaRostoDTO (com.tomasio.projects.trainning.dto.FolhaRostoDTO)3 TurmaDTO (com.tomasio.projects.trainning.dto.TurmaDTO)3 TurmaPlanejadaDTO (com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)3 Anotacao (com.tomasio.projects.trainning.model.Anotacao)3 Calendar (java.util.Calendar)3 List (java.util.List)3 HibernateException (org.hibernate.HibernateException)3 Session (org.hibernate.Session)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3