Example usage for org.hibernate Session saveOrUpdate

List of usage examples for org.hibernate Session saveOrUpdate

Introduction

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

Prototype

void saveOrUpdate(Object object);

Source Link

Document

Either #save(Object) or #update(Object) the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).

Usage

From source file:com.levinas.ecole.dao.AnneeScolaireDaoImpl.java

@Override
public void saveOrUpdate(AnneeScolaire anneeScolaire) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(anneeScolaire);
}

From source file:com.levinas.ecole.dao.ClasseDaoImpl.java

@Override
public void saveOrUpdate(Classe classe) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(classe);
}

From source file:com.levinas.ecole.dao.EnfantDaoImpl.java

@Override
public void saveOrUpdate(Enfant enfant) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(enfant);
}

From source file:com.levinas.ecole.dao.EtablissementDaoImpl.java

@Override
public void saveOrUpdate(Etablissement etablissement) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(etablissement);
}

From source file:com.levinas.ecole.dao.PersonnelDaoImpl.java

@Override
public void saveOrUpdate(Personnel personnel) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(personnel);
}

From source file:com.levinas.ecole.dao.ResponsableDaoImpl.java

@Override
public void saveOrUpdate(Responsable responsable) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(responsable);
}

From source file:com.levinas.ecole.dao.TypeResponsableDaoImpl.java

@Override
public void saveOrUpdate(TypeResponsable typeResponsable) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(typeResponsable);
}

From source file:com.levinas.ecole.dao.UserDaoImpl.java

@Override
public void saveOrUpdate(User user) {
    Session session = sessionFactory.getCurrentSession();
    session.saveOrUpdate(user);
}

From source file:com.liusoft.dlog4j.dao.DAO.java

License:Open Source License

/**
 * /* w w  w  .  j  av  a2  s.  com*/
 * @param cbean
 */
public static void saveOrUpdate(Object cbean) {
    try {
        Session ssn = getSession();
        beginTransaction();
        ssn.saveOrUpdate(cbean);
        commit();
    } catch (HibernateException e) {
        rollback();
        throw e;
    }
}

From source file:com.manage.Product_maneger.java

public static void updateProduct(Products pro) {
    Transaction trns = null;//from w ww  .j  a  v a2 s. co  m
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        //
        Products lolo = new Products();
        lolo.setId(pro.getId());
        lolo.setName(pro.getName());
        lolo.setAvalibleAmmount(pro.getAvalibleAmmount());
        lolo.setUnit(pro.getUnit());
        lolo.setDescription(pro.getDescription());
        //
        session.saveOrUpdate(lolo);

        session.getTransaction().commit();
    } catch (RuntimeException e) {
        if (trns != null) {
            trns.rollback();
        }
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
}