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:com.actop.model.ApprovalManagement.java

public AllowanceApproval approveAllowance(int id, String note, Integer status) {
    Session s = Connection.getSessionFactory().openSession();
    AllowanceApproval approval = (AllowanceApproval) s.load(AllowanceApproval.class, id);
    Transaction t = s.beginTransaction();
    try {//from w w  w.ja v a 2s  .  co  m
        approval.setApprovedtime(new Date());
        approval.setNote(note);
        approval.setStatus(status);
        s.update(t);
    } catch (Exception e) {
        e.printStackTrace();
        t.rollback();
    }
    t.commit();
    s.flush();
    s.close();
    return approval;
}

From source file:com.actop.model.PermissionManagement.java

public InterfacesHasUserLogin updateInterfacesHasUserLogin(Interfaces interfacedb, Integer delete, Integer save,
        Integer search, Integer permissionType, Integer update, UserLogin uLogin, int id) {
    if (loadPermission(uLogin, interfacedb)) {
        Session s = Connection.getSessionFactory().openSession();
        Transaction t = s.beginTransaction();
        InterfacesHasUserLogin hasUserLogin = (InterfacesHasUserLogin) s.load(InterfacesHasUserLogin.class, id);
        try {//ww  w.  ja  va2 s  .  c o m
            hasUserLogin.setInterfaces(interfacedb);
            hasUserLogin.setPermissionDelete(delete);
            hasUserLogin.setPermissionSave(save);
            hasUserLogin.setPermissionSearch(search);
            hasUserLogin.setPermissionType(permissionType);
            hasUserLogin.setPermissionUpdate(update);
            hasUserLogin.setUserLogin(uLogin);
            s.update(hasUserLogin);
        } catch (Exception e) {
            t.rollback();
            e.printStackTrace();
        }
        t.commit();
        s.flush();
        s.close();
        return hasUserLogin;
    }
    return null;
}

From source file:com.actop.model.PromotionManagement.java

public Promotions promoteEmployer(int pid, String promotBy, Date approvedDate, String promotionApprovedBy,
        Date effectiveDate, String promotionStates) {
    Session s = Connection.getSessionFactory().openSession();
    Promotions p = (Promotions) s.load(Promotions.class, pid);
    Transaction t = s.beginTransaction();
    try {/*from ww w.j a va  2s  .  com*/
        Criteria c = s.createCriteria(DepartmentsHasDesignation.class);
        c.add(Restrictions.eq("employers", p.getEmployers()));
        DepartmentsHasDesignation dhd = (DepartmentsHasDesignation) c.uniqueResult();
        Criteria c1 = s.createCriteria(Designation.class);
        c1.add(Restrictions.eq("designation", p.getPromotionFor()));
        Designation d = (Designation) c.uniqueResult();
        dhd.setDesignation(d);
        s.update(dhd);
        p.setPromotBy(convertToBytes(promotBy));
        //            p.setPromotionApproved(approvedDate);
        //            p.setPromotionApprovedBy(convertToBytes(promotionApprovedBy));
        p.setPromotionEffectiveDate(effectiveDate);
        p.setPromotionStates(convertToBytes(promotionStates));
        s.update(p);
    } catch (Exception e) {
        t.rollback();
    }
    t.commit();
    s.flush();
    s.close();
    return p;
}

From source file:com.adsapient.shared.dao.HibernateEntityDao.java

License:Open Source License

public void updateObject(final Object obj) {
    getHibernateTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException {
            session.setCacheMode(CacheMode.IGNORE);
            session.update(obj);
            sendUpdateEventToAdserver(obj.getClass(), ((IMappable) obj).getId(), null);
            return obj;
        }//from w  w  w.  ja  v a 2s  .  c om
    });
}

From source file:com.alejandro.modelo.ModeloImagen.java

public static void edit(Imagen p) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/*from w  ww.  j a  v a2s  .  c o m*/

    session.update(p);

    session.getTransaction().commit();
    session.flush();
    session.close();
}

From source file:com.alejandro.modelo.ModeloInmueble.java

public static void edit(Inmueble p) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();//from   w ww  .jav a 2s  .  co m

    session.update(p);

    session.getTransaction().commit();
    session.flush();
    session.close();
}

From source file:com.almacen.dao.articuloDaoImp.java

@Override
public Articulo guardaArticulo(Articulo articulo) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction transaction = session.beginTransaction();
    try {/*w ww  .  j av a  2 s . c o m*/

        if (articulo.getIdArticulo() == null || articulo.getIdArticulo() == 0) {
            session.save(articulo);
            transaction.commit();

        } else {
            session.update(articulo);
            transaction.commit();
        }
        session.close();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        transaction.rollback();
    }
    return articulo;
}

From source file:com.almacen.dao.articuloentradaDaoImp.java

@Override
public ArticuloEntrada guardaArticuloEntrada(ArticuloEntrada artEnt) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction transaction = session.beginTransaction();
    try {//from   ww w  .  j ava2 s. c  o m

        if (artEnt.getIdArticuloEntrada() == null || artEnt.getIdArticuloEntrada() == 0) {
            System.out.println("***** entra al if guardar articulo entrada ******");
            session.save(artEnt);
            transaction.commit();

        } else {
            System.out.println(
                    "***** entra al else modifica articulo entrada ******" + artEnt.getIdArticuloEntrada());
            session.update(artEnt);
            transaction.commit();

        }
        session.close();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        transaction.rollback();
    }
    return artEnt;
}

From source file:com.almacen.dao.articuloentradaDaoImp.java

@Override
public ArticuloEntrada actualizarArticuloEntrada(ArticuloEntrada artEnt) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction transaction = session.beginTransaction();
    try {/*from w w  w  .j a v  a 2 s.co m*/

        System.out.println(
                "***** entra al else modifica articulo entrada ******" + artEnt.getIdArticuloEntrada());
        session.update(artEnt);
        transaction.commit();
        session.close();

    } catch (Exception e) {
        System.out.println(e.getMessage());
        transaction.rollback();
    }
    return artEnt;
}

From source file:com.almacen.dao.departamentoDaoImp.java

@Override
public Departamento actualizaDepto(Departamento depto) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction transaction = session.beginTransaction();
    try {//from   w ww  .  j  a  va2  s. com

        session.update(depto);
        transaction.commit();
        session.close();

    } catch (Exception e) {
        System.out.println(e.getMessage());
        transaction.rollback();
    }
    return depto;
}