Example usage for org.hibernate Session merge

List of usage examples for org.hibernate Session merge

Introduction

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

Prototype

Object merge(Object object);

Source Link

Document

Copy the state of the given object onto the persistent object with the same identifier.

Usage

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public void updateSubject(SubjectVO subjectVO) throws ArkUniqueException {
    Session session = getSession();

    Person person = subjectVO.getLinkSubjectStudy().getPerson();
    String currentLastNameFromDB = getCurrentLastnameFromDB(person);// may need to test this effect of a reget

    session.update(person);// Update Person and associated Phones

    PersonLastnameHistory personLastNameHistory = null;

    if (currentLastNameFromDB != null && !currentLastNameFromDB.isEmpty()
            && !currentLastNameFromDB.equalsIgnoreCase(person.getLastName())) {
        if (person.getLastName() != null) {
            personLastNameHistory = new PersonLastnameHistory();
            personLastNameHistory.setPerson(person);
            personLastNameHistory.setLastName(currentLastNameFromDB);
            session.save(personLastNameHistory);
        }// w  w  w .j a  v a 2s .  com
    }

    // Update subjectPreviousLastname
    if (personLastNameHistory != null) {
        subjectVO.setSubjectPreviousLastname(getPreviousLastname(person));
    }

    LinkSubjectStudy linkSubjectStudy = subjectVO.getLinkSubjectStudy();
    session.merge(linkSubjectStudy);
}

From source file:au.org.theark.study.model.dao.StudyDao.java

License:Open Source License

public void update(Consent consent) throws ArkSystemException, EntityNotFoundException {
    try {//from w  w  w .jav  a  2  s .  c o  m
        Session session = getSession();
        session.merge(consent);
    } catch (HibernateException someHibernateException) {
        log.error("An Exception occured while trying to update this consent "
                + someHibernateException.getStackTrace());
    } catch (Exception e) {
        log.error("An Exception occured while trying to update this consent " + e.getStackTrace());
        throw new ArkSystemException(
                "A System Error has occured. We wil have someone contact you regarding this issue");
    }

}

From source file:automatedbillingsoftware_DA.ChallanDA.java

public void deleteChallanGen(int id) {
    SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory();
    Session session = sessionFactory.openSession();
    ChallanGenerated cg = fetchChallanGenById(id);
    System.out.println("id=>" + id + "cg=>" + cg);
    if (cg != null) {
        Transaction beginTransaction = session.beginTransaction();
        cg.setStatus(0);//from w  w w .  ja  v a 2  s .co m
        session.merge(cg);
        session.flush();
        System.out.println("cg=>" + cg.getStatus());
        //        challan.setStatus(1);
        //        session.persist(challan);
        beginTransaction.commit();
    }

    //     return challan;
}

From source file:baza.Broker.java

public boolean sacuvajIzmeneLekara(Lekar l) {
    boolean uspesno = false;
    Session session = Test.getSessionFactory().openSession();
    try {/*from  w ww.j  ava  2  s. c  o m*/

        session.beginTransaction();
        Lekar lekar = (Lekar) session.get(Lekar.class, l.getLekarID());
        session.merge(l);
        session.getTransaction().commit();
        uspesno = true;
    } catch (HibernateException hibernateException) {
        session.getTransaction().rollback();
    } finally {
        session.close();
    }
    return uspesno;
}

From source file:baza.Broker.java

public boolean sacuvajIzmenePacijenta(Pacijent p) {
    boolean uspesno = false;
    Session session = Test.getSessionFactory().openSession();
    try {/*from   w ww. ja  va  2 s.  co  m*/

        session.beginTransaction();
        Pacijent pacijent = (Pacijent) session.get(Pacijent.class, p.getJMBGPacijenta());
        session.merge(p);
        session.getTransaction().commit();
        uspesno = true;
    } catch (HibernateException hibernateException) {
        session.getTransaction().rollback();
    } finally {
        session.close();
    }
    return uspesno;
}

From source file:bookstore.dao.generic.GenericDAOImpl.java

public void merge(T entity) {
    Session hibernateSession = this.getSession();
    hibernateSession.merge(entity);
}

From source file:br.com.Dao.HibernateDao.java

@Override
public void merge(T entity) {
    Session.merge(entity);
}

From source file:br.com.gaiatosfc.DAO.JogadoresDAOImp.java

@Override
public void atualizar(Jogadores jogador) throws DAOException {
    Session session = null;
    try {/*from w ww  .  ja va  2  s .c o  m*/
        session = HibernateUtil.getSessionFactory().openSession();
        Transaction t = session.beginTransaction();

        session.merge(jogador);
        t.commit();
    } catch (Exception e) {
        session.getTransaction().rollback();
        throw new DAOException(e);
    } finally {
        if (session != null) {
            session.close();
        }
    }
}

From source file:br.com.moises.dao.Dao.java

@Override
public boolean merge(T entity) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    try {/*ww w  .j  a va 2s  .  c  o m*/

        session.getTransaction().begin();
        session.merge(entity);
        session.getTransaction().commit();
        FacesUtil.addInfoMessage("Sincronizado com sucesso!!");
        return true;
    } catch (Exception e) {
        session.getTransaction().rollback();
        FacesUtil.addInfoMessage("Erro ao sincronizar!!!" + e);
        return false;
    }
}

From source file:br.com.nfsconsultoria.nfsuporte.dao.GenericDAO.java

public void merge(Entidade entidade) {
    Session sesao = HibernateUtil.getFabricaDeSessoes().openSession();
    Transaction transacao = null;//w w w .  j a v  a 2  s .com

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