Example usage for org.hibernate Session update

List of usage examples for org.hibernate Session update

Introduction

In this page you can find the example usage for org.hibernate Session update.

Prototype

void update(Object object);

Source Link

Document

Update the persistent instance with the identifier of the given detached instance.

Usage

From source file:br.com.sescacre.sisrelat.dao.HistoricoChamadaDao.java

public void alterar(HistoricoChamada hc) throws Exception {
    Session s = HibernateUtil.getSession();
    try {// w w  w. ja  va  2 s .  c om
        Transaction t = s.beginTransaction();
        s.update(hc);
        t.commit();
    } catch (Exception e) {
        throw new SQLIntegrityConstraintViolationException();
    } finally {
        s.close();
    }
}

From source file:br.com.sigcopex.dao.CursoDAO.java

public void editar(Curso curso) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;//from  www. j  a v  a2s.c  o m

    try {
        transacao = sessao.beginTransaction();
        sessao.update(curso);
        transacao.commit();
    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw ex;
    } finally {
        sessao.close();
    }
}

From source file:br.com.sigcopex.dao.DisciplinaDAO.java

public void editar(Disciplina disciplina) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;//w  w  w .  jav a  2s  .  c o m

    try {
        transacao = sessao.beginTransaction();
        sessao.update(disciplina);
        transacao.commit();
    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw ex;
    } finally {
        sessao.close();
    }
}

From source file:br.com.sigcopex.dao.ExtensaoDAO.java

public void editar(Extensao extensao) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;/*from w w w . j  a va2 s .  c o m*/

    try {
        transacao = sessao.beginTransaction();
        sessao.update(extensao);
        transacao.commit();
    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw ex;
    } finally {
        sessao.close();
    }
}

From source file:br.com.sigcopex.dao.MonitoriaDAO.java

public void editar(Monitoria monitoria) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;//w ww  . ja v  a 2  s. c om

    try {
        transacao = sessao.beginTransaction();
        sessao.update(monitoria);
        transacao.commit();
    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw ex;
    } finally {
        sessao.close();
    }
}

From source file:br.com.sigcopex.dao.ProfessorDAO.java

public void editar(Professor professor) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;//from   www. j  a  va 2 s .c om

    try {
        transacao = sessao.beginTransaction();
        sessao.update(professor);
        transacao.commit();
    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw ex;
    } finally {
        sessao.close();
    }
}

From source file:br.com.sigcopex.dao.TermoAutorizacaoExtensaoDAO.java

public void editar(TermoAutorizacaoExtensao termoAutorizacaoExtensao) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;//w ww .j a v a  2s.c  o m

    try {
        transacao = sessao.beginTransaction();
        sessao.update(termoAutorizacaoExtensao);
        transacao.commit();
    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw ex;
    } finally {
        sessao.close();
    }
}

From source file:br.com.t2ti.balcao.ProdutoDetalheController.java

License:Open Source License

@Override
public Response updateRecord(ValueObject oldPersistentObject, ValueObject persistentObject) throws Exception {
    Session session = null;
    try {/*ww w .j  a va 2  s  . c o  m*/
        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();
        ProdutoVO produto = (ProdutoVO) persistentObject;

        String sql = "select PRODUTO from br.com.t2ti.vo.ProdutoVO as PRODUTO where PRODUTO.gtin = "
                + produto.getGtin() + " and PRODUTO.id <> " + produto.getId();

        produto = (ProdutoVO) session.createQuery(sql).uniqueResult();
        if (produto != null) {
            return new ErrorResponse("Cdigo de produto j cadastrado!");
        }

        produto = (ProdutoVO) persistentObject;
        produto.setHashIncremento(-1);
        session.update(produto);
        session.getTransaction().commit();
        return new VOResponse(produto);
    } catch (Exception e) {
        e.printStackTrace();
        session.getTransaction().rollback();
        return new ErrorResponse("Erro ao cadastrar o produto!");
    } finally {
        session.close();
    }
}

From source file:br.com.tpartner.persistence.crud.implementation.GenericCRUDImplementation.java

@Override
public T update(T entity) {
    Session session = getCurrentSession();
    Transaction tx = session.beginTransaction();
    session.update(entity);
    tx.commit();/*from   ww  w  .  ja  va  2 s  .com*/
    session.close();
    return entity;
}

From source file:br.com.ufmt.fata.dao.ComplementoDaoImp.java

@Override
public void update(Complemento complemento) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.update(complemento);
    t.commit();/*  www  .j  a  v  a2  s  . c  o m*/
    session.close();
}