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.proj.tasker.dao.impl.UsuarioDAO.java

@Override
public void alterarUsuario(Usuario usuario) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/* www. j  a va2  s .  c  o  m*/
        session.getTransaction().begin();
        session.update(usuario);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao atualizar: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

From source file:br.com.projetoweb.model.dao.LivroDAOImp.java

public void update(Livro livro) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.update(livro);
    t.commit();//from   w  ww  .ja v  a 2 s. co m

}

From source file:br.com.railsos.os.dao.GenericDAO.java

/**
 * Metdo editar Edita variaveis do banco
 *
 * @author Rafael/* www.  jav a  2 s .  c om*/
 */
public void editar(Entidade entidade) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;

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

From source file:br.com.rhmanager.daoImpl.HibernateDAO.java

@Transactional
public void update(Object obj) throws Exception {
    Session session = null;
    Transaction transaction = null;/*  ww  w. j  ava 2  s .co  m*/

    try {
        session = HibernateUtil.getSession();
        transaction = session.beginTransaction();
        session.update(obj);
        session.flush();
        transaction.commit();

    } finally {
        session.close();

    }
}

From source file:br.com.sescacre.controleAcesso.dao.CargosDAO.java

public void alterar(Cargos cargo) throws Exception {
    Session s = HibernateUtil.getSession();
    try {//from   w  w w.j ava  2 s.com
        Transaction t = s.beginTransaction();
        s.update(cargo);
        t.commit();
    } catch (Exception e) {
        throw new SQLIntegrityConstraintViolationException();
    } finally {
        s.close();
    }
}

From source file:br.com.sescacre.controleAcesso.dao.CargosDoSetorDAO.java

public void alterar(CargosDoSetor cds) {
    Session s = HibernateUtil.getSession();
    Transaction t = s.beginTransaction();
    s.update(cds);
    t.commit();//from  w  w w  .  j  a va2s  .c  om
    s.close();
}

From source file:br.com.sescacre.controleAcesso.dao.CategoriasDao.java

public void alterar(Categorias cat) throws Exception {
    Session s = HibernateUtil.getSession();
    try {//www .j  ava  2  s  .c  o  m
        Transaction t = s.beginTransaction();
        s.update(cat);
        t.commit();
    } catch (Exception e) {
        throw new SQLIntegrityConstraintViolationException();
    } finally {
        s.close();
    }
}

From source file:br.com.sescacre.controleAcesso.dao.FuncionariosDao.java

public void alterar(Funcionarios user) throws Exception {
    Session s = HibernateUtil.getSession();
    try {//ww w  .ja v a 2s .  com
        Transaction t = s.beginTransaction();
        s.update(user);
        t.commit();
    } catch (Exception ex) {
        throw new SQLIntegrityConstraintViolationException(
                "J existe um Funcionrio cadastrado com essa matrcula!");
    } finally {
        s.close();
    }

}

From source file:br.com.sescacre.controleAcesso.dao.RegistroDao.java

public void alterar(Registros r) throws Exception {
    Session s = HibernateUtil.getSession();
    Transaction t = null;//from   w  w w. j av a  2s  .c om
    try {
        t = s.beginTransaction();
        s.update(r);
        t.commit();
    } catch (Exception e) {
        t.rollback();
        throw new SQLIntegrityConstraintViolationException();
    } finally {
        s.close();
    }
}

From source file:br.com.sescacre.controleAcesso.dao.SetoresDAO.java

public void alterar(Setores setor) throws Exception {
    Session s = HibernateUtil.getSession();
    try {/*from   w ww  .  j av a2  s . co m*/
        Transaction t = s.beginTransaction();
        s.update(setor);
        t.commit();
    } catch (Exception e) {
        throw new SQLIntegrityConstraintViolationException();
    } finally {
        s.close();
    }
}