use of com.tomasio.projects.trainning.model.Anotacao in project trainning by fernandotomasio.
the class HibernateAnotacaoDAO method findAll.
@Override
public List<AnotacaoDTO> findAll() throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
@SuppressWarnings("unchecked") List<Anotacao> anotacoes = session.createQuery("from Anotacao anotacao order by anotacao.dataCriacao desc").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"));
}
}
use of com.tomasio.projects.trainning.model.Anotacao in project trainning by fernandotomasio.
the class HibernateAnotacaoDAO method findAllByUser.
@Override
public List<AnotacaoDTO> findAllByUser(String user) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
@SuppressWarnings("unchecked") List<Anotacao> anotacoes = session.createQuery("from Anotacao anotacao" + " where anotacao.user=:user order by anotacao.dataCriacao desc").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"));
}
}
use of com.tomasio.projects.trainning.model.Anotacao in project trainning by fernandotomasio.
the class HibernateAnotacaoDAO method remove.
@Override
public void remove(Long id) throws DAOException {
Session session = sessionFactory.getCurrentSession();
Anotacao anotacao = (Anotacao) session.get(Anotacao.class, id);
try {
session.delete(anotacao);
} catch (HibernateException e) {
Logger.getLogger(HibernateAnotacaoDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("anotacoes.remove.error"));
}
}
use of com.tomasio.projects.trainning.model.Anotacao in project trainning by fernandotomasio.
the class HibernateAnotacaoDAO method update.
@Override
public void update(AnotacaoDTO anotacao) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
Anotacao _anotacao = new Anotacao(anotacao);
session.update(_anotacao);
} catch (HibernateException e) {
Logger.getLogger(HibernateAnotacaoDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("anotacoes.update.error"));
}
}
use of com.tomasio.projects.trainning.model.Anotacao 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