use of com.tomasio.projects.trainning.model.NotificacaoMatricula in project trainning by fernandotomasio.
the class AtividadesEnsinoServiceSimpleImpl method createNotificacaoMatricula.
@Override
@Transactional
public Long createNotificacaoMatricula(NotificacaoMatriculaDTO notificacaoMatricula) {
NotificacaoMatriculaDAO dao = factory.getNotificacaoMatriculaDAO();
Long id = null;
NotificacaoMatricula _notificacaoMatricula = null;
// cria um registro na tabela CancelamentoMatricula
if (notificacaoMatricula != null) {
_notificacaoMatricula = new NotificacaoMatricula(notificacaoMatricula);
}
try {
id = dao.create(_notificacaoMatricula);
} catch (DAOException ex) {
ex.printStackTrace();
throw new CoreException(ex.getMessage());
} catch (Exception ex) {
ex.printStackTrace();
throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
// throw new CoreException(ex.getMessage());
}
return id;
}
use of com.tomasio.projects.trainning.model.NotificacaoMatricula in project trainning by fernandotomasio.
the class HibernateNotificacaoMatriculaDAO method create.
@Override
public void create(List<NotificacaoMatricula> notificacaoMatriculas) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
for (NotificacaoMatricula notificacaoMatricula : notificacaoMatriculas) {
Long countNotificacaoMatricula = (Long) session.createQuery("" + "select count(*) " + "from NotificacaoMatricula n " + "where n.matricula.id = :matriculaId").setLong("matriculaId", notificacaoMatricula.getMatricula().getId()).uniqueResult();
if (countNotificacaoMatricula > 0) {
throw new DAOException("Notificação de Matricula já existente");
}
session.save(notificacaoMatricula);
}
} catch (HibernateException e) {
Logger.getLogger(HibernateMatriculaDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("notificacaoMatricula.create.list.error"));
}
}
use of com.tomasio.projects.trainning.model.NotificacaoMatricula in project trainning by fernandotomasio.
the class HibernateNotificacaoMatriculaDAO method remove.
@Override
public void remove(Long notificacaoMatriculaId) throws DAOException {
Session session = sessionFactory.getCurrentSession();
NotificacaoMatricula notificacaoMatricula = (NotificacaoMatricula) session.get(NotificacaoMatricula.class, notificacaoMatriculaId);
try {
session.delete(notificacaoMatricula);
} catch (HibernateException e) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("notificacaoMatricula.remove.error"));
}
}
Aggregations