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"));
}
}
Aggregations