Search in sources :

Example 1 with Posto

use of com.tomasio.projects.trainning.model.Posto in project trainning by fernandotomasio.

the class OrganizationalServiceSimpleImpl method findPosto.

@Override
@Transactional(readOnly = true)
public PostoDTO findPosto(Long id) {
    PostoDAO dao = factory.getPostoDAO();
    Posto posto;
    try {
        posto = dao.find(id);
        if (posto != null) {
            return posto.createDTO();
        } else {
            return null;
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Posto(com.tomasio.projects.trainning.model.Posto) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Posto

use of com.tomasio.projects.trainning.model.Posto in project trainning by fernandotomasio.

the class OrganizationalServiceSimpleImpl method findPostoBySigla.

@Override
@Transactional(readOnly = true)
public PostoDTO findPostoBySigla(String sigla) {
    PostoDAO dao = factory.getPostoDAO();
    Posto posto;
    try {
        posto = dao.findBySigla(sigla);
        if (posto != null) {
            return posto.createDTO();
        } else {
            return null;
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Posto(com.tomasio.projects.trainning.model.Posto) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Posto

use of com.tomasio.projects.trainning.model.Posto in project trainning by fernandotomasio.

the class OrganizationalServiceSimpleImpl method updatePosto.

@Override
@Transactional
public void updatePosto(PostoDTO posto) {
    PostoDAO dao = factory.getPostoDAO();
    Posto model = new Posto(posto);
    try {
        dao.update(model);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Posto(com.tomasio.projects.trainning.model.Posto) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Posto

use of com.tomasio.projects.trainning.model.Posto in project trainning by fernandotomasio.

the class OrganizationalServiceSimpleImpl method createPosto.

@Override
@Transactional
public Long createPosto(PostoDTO posto) {
    PostoDAO dao = factory.getPostoDAO();
    Posto model = new Posto(posto);
    Long id = null;
    try {
        id = dao.create(model);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return id;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Posto(com.tomasio.projects.trainning.model.Posto) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Posto

use of com.tomasio.projects.trainning.model.Posto in project trainning by fernandotomasio.

the class HibernatePostoDAO method remove.

@Override
public void remove(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Posto posto = (Posto) session.get(Posto.class, id);
        session.delete(posto);
    } catch (HibernateException e) {
        Logger.getLogger(HibernatePostoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException("Erro ao remover Posto!");
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Posto(com.tomasio.projects.trainning.model.Posto) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)6 Posto (com.tomasio.projects.trainning.model.Posto)6 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 Transactional (org.springframework.transaction.annotation.Transactional)5 PostoDTO (com.tomasio.projects.trainning.dto.PostoDTO)1 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1