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.ufmt.fata.dao.PastaDeComunicacaoDaoImp.java

@Override
public void update(PastaDeComunicacao pastaDeComunicacao) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.update(pastaDeComunicacao);
    t.commit();//  w  w  w.  j av  a  2  s. c o  m
    session.close();
}

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

@Override
public void update(Sujeito sujeito) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.update(sujeito);
    t.commit();/*from   w  ww. jav  a  2 s .co  m*/
    session.close();
}

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

@Override
public void update(Verbo verbo) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.update(verbo);
    t.commit();//from   w w w  .  j ava2  s. c  o m
    session.close();
}

From source file:br.com.wservice.dao.LabRequisicaoDao.java

/**
 * Toma a decisao de fazer ou nao o save/update/nada  na LabRequisicao de acordo com o legStCodigo
 * @param labRequisicao//from   w  w  w.j a  v a2 s .com
 * @param session 
 */
private void switchCaseLegStCodigo(LabRequisicao labRequisicao, Session session) {
    String legStCodigo = labRequisicao.getLegStCodigo();
    switch (legStCodigo) {
    case "001":
        //                System.out.println("case 001:");
    case "002":
        System.out.println("Status da requisio : " + legStCodigo);
        session.update(labRequisicao);
        break;
    case "003":
        System.out.println("case 003:");
        break;
    case "004":
        System.out.println("case 004:");
        break;
    case "005":
        System.out.println("case 005:");
        break;
    case "006":
        System.out.println("case 006:");
        break;
    case "007":
        System.out.println("case 007:");
        break;
    case "011":
        System.out.println("case 011:");
        break;
    default:
        System.out.println("case default:  legStCodigo = " + legStCodigo);
    }
}

From source file:br.com.wservice.LabRequisicaoFixingDatas.java

/**
 * Pega LabRequisicao e a lista de LabDetalheRequisicao de novos exame  e faz o
 * update nas datas de Fatura// www .ja  v a 2s  .c o m
 *
 * @param reqStCodigo
 * @param xmlSolicitacao
 */
public static void arrumandoDatas(String reqStCodigo, List<LabDetalheRequisicao> listNewExames,
        String strDbName) {
    if (listNewExames != null && !listNewExames.isEmpty()) {
        Session session = null;
        try {
            session = SessionFactoriByDBName.getCurrentSession4FacesByDbName(strDbName);
            Transaction tx = session.beginTransaction();
            LabRequisicao labRequisicao = (LabRequisicao) session.get(LabRequisicao.class,
                    new Long(reqStCodigo));
            //                if(labRequisicao.isSalvoNoDb()){}

            for (LabDetalheRequisicao labDetalheRequisicao : listNewExames) {
                labDetalheRequisicao.setDerDtFatura(labRequisicao.getReqDtCadastro());
                labDetalheRequisicao.setReqDtCadastro(labRequisicao.getReqDtCadastro());
                session.update(labDetalheRequisicao);
            }
            tx.commit();
        } catch (HibernateException xcp) {
            xcp.printStackTrace();
        } finally {
            if (session != null) {
                session.close();
            }
        }
    } else {
        System.out.println("No h novos exames para arrumar a data da fatura.");
    }

}

From source file:br.edu.ifes.bd2hibernate.cgd.DAO.java

public void atualizar(Object obj, Class c) {
    Session s = HibernateUtil.getSession();
    HibernateUtil.begin();//from   w  w w .  jav  a2s .co  m

    s.update(c.cast(obj));

    HibernateUtil.commit();
    HibernateUtil.close();
}

From source file:br.edu.ifsp.dsw.dao.impl.TagDAOImpl.java

@Override
public void atualizarTag(Tag t) {
    Session session = this.sessionFactory.getCurrentSession();
    session.update(t);
    logger.info("Tag atualizada com sucesso, detalhes da tag=" + t);
}

From source file:br.edu.ifsp.dsw.dao.impl.UsuarioDAOImpl.java

@Override
public void atualizarUsuario(Usuario u) {
    Session session = this.sessionFactory.getCurrentSession();
    session.update(u);
    logger.info("Usuario incluido com sucesso, detalhes =" + u);
}

From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java

public List<AbstractEntity> update(AbstractEntity obj) throws DAOException {

    List<AbstractEntity> lista = new ArrayList<AbstractEntity>();

    try {//from w w w.j av  a 2s. co  m
        Session session = currentSession();
        session.setCacheMode(CacheMode.GET);
        session.update(obj);
        session.flush();
        lista.add(obj);
        return lista;
    } catch (HibernateException e) {
        throw new DAOException(e);
    }
}

From source file:br.sp.telesul.dao.FuncionarioDAOImpl.java

@Override
public void update(Funcionario funcionario) {
    Session session = this.sessionFactory.openSession();
    try {//from   w  ww  .  j  a v a2 s  .co  m
        tx = session.beginTransaction();
        session.update(funcionario);
        tx.commit();
        logger.info("Update Sucessfully funcionrio", funcionario.getNome());
    } catch (Exception e) {
        if (tx != null) {
            tx.rollback();
        }
        logger.error("Error in update funcionrio", e);
        System.out.println("erro" + e);
    } finally {
        session.close();
    }

}