Search in sources :

Example 1 with NotificacaoMatricula

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;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) NotificacaoMatriculaDAO(com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) NotificacaoMatricula(com.tomasio.projects.trainning.model.NotificacaoMatricula) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with NotificacaoMatricula

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"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) NotificacaoMatricula(com.tomasio.projects.trainning.model.NotificacaoMatricula) Session(org.hibernate.Session)

Example 3 with NotificacaoMatricula

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"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) NotificacaoMatricula(com.tomasio.projects.trainning.model.NotificacaoMatricula) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)3 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)3 HibernateException (org.hibernate.HibernateException)2 Session (org.hibernate.Session)2 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)1 CoreException (com.tomasio.projects.trainning.exeption.CoreException)1 ParseException (java.text.ParseException)1 Transactional (org.springframework.transaction.annotation.Transactional)1