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:backend.api.Statistics.java

public void setRecordsMonitoringWorkers(MonitoringWorkers m) {
    Session session = sf.openSession();
    try {//from w  ww .  ja v  a2  s  .  c  om
        Transaction tx = session.beginTransaction();

        session.update(m);
        tx.commit();

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
    }
}

From source file:backend.api.StorageManagement.java

public void editProduct(Products product) //ok
{
    Session session = SessionFactoryManager.INSTANCE.getSessionFactory().openSession();
    try {//  ww w.j a v  a  2 s.  c o m
        Transaction tx = session.beginTransaction();

        session.update(product);
        tx.commit();

    } finally {
        session.close();
    }
}

From source file:backend.api.StorageManagement.java

public void editCategory(Category cat) //ok
{
    Session session = SessionFactoryManager.INSTANCE.getSessionFactory().openSession();
    try {/*from  w  w w  .j av  a2s.c o  m*/
        Transaction tx = session.beginTransaction();

        session.update(cat);
        tx.commit();

    } finally {
        session.close();
    }
}

From source file:backend.api.StorageManagement.java

public void editManufacturer(Manufacturers man)//ok
{
    Session session = SessionFactoryManager.INSTANCE.getSessionFactory().openSession();
    try {//from  w ww. ja  v  a2s.  c om
        Transaction tx = session.beginTransaction();

        session.update(man);
        tx.commit();

    } finally {
        session.close();
    }
}

From source file:backend.api.StorageManagement.java

public void editAttributes(Attributes at) //ok
{
    Session session = SessionFactoryManager.INSTANCE.getSessionFactory().openSession();
    try {//  ww w.j  a  v  a  2s  .  c  om
        Transaction tx = session.beginTransaction();

        session.update(at);
        tx.commit();

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
    }
}

From source file:baking.dao.BaseDao.java

License:Open Source License

/**
 * /*from w w w  .jav  a2s. com*/
 * @description   
 * @author  JiaCao
 * @param obj  
 */

public void update(Object obj) {
    try {
        Session session = getSession();
        session.update(obj);
    } catch (RuntimeException re) {
        throw re;
    }
}

From source file:basedistribuida.connection.HibernateSession.java

protected boolean update(Object clazz) {
    Session session = sessionFactory.openSession();
    try {/*from w  ww. j a  v  a2 s  .c om*/
        session.beginTransaction();
        session.update(clazz);
        session.getTransaction().commit();
    } finally {
        session.close();
    }
    return true;
}

From source file:bazydanych.CRUDTest.java

public void updateCar(Integer ID, int cena) {
    Session session = factory.openSession();
    Transaction tx = null;/*w w w . j  av a 2  s . co  m*/
    try {
        tx = session.beginTransaction();
        Samochod car = (Samochod) session.get(Samochod.class, ID);
        car.setCena(cena);
        session.update(car);
        tx.commit();
    } catch (HibernateException e) {
        if (tx != null)
            tx.rollback();
        e.printStackTrace();
    } finally {
        session.close();
    }
}

From source file:bazydanych.KsiazkiTest.java

private void updateBook(Integer bookID, String title, Set heroes) {
    Session session = factory.openSession();
    Transaction tx = null;//from  ww  w . ja  v a 2s  . c o m
    try {
        tx = session.beginTransaction();
        Ksiazka book = (Ksiazka) session.get(Ksiazka.class, bookID);
        if (title != null) {
            book.setTytul(title);
        }
        if (heroes != null) {
            book.setBohaterowie(heroes);
        }
        session.update(book);
        tx.commit();
    } catch (HibernateException e) {
        if (tx != null) {
            tx.rollback();
        }
        e.printStackTrace();
        fail();
    } finally {
        session.close();
    }
}

From source file:bazydanych.ManageEmployee.java

public void updateEmployee(Integer EmployeeID, int salary) {
    Session session = factory.openSession();
    Transaction tx = null;// ww  w.  j  av  a  2s  . c  om
    try {
        tx = session.beginTransaction();
        Employee employee = (Employee) session.get(Employee.class, EmployeeID);
        employee.setSalary(salary);
        session.update(employee);
        tx.commit();
    } catch (HibernateException e) {
        if (tx != null)
            tx.rollback();
        e.printStackTrace();
    } finally {
        session.close();
    }
}