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:app.datos.servicios.implementacion.PropietarioServiceImpl.java

License:Open Source License

@Override
@Transactional(rollbackFor = PersistenciaException.class) //si falla hace rollback de la transaccin
public void modificarPropietario(Propietario propietario) throws PersistenciaException {
    Session session = getSessionFactory().getCurrentSession();
    try {// ww w  .  jav  a 2s.  c  o  m
        session.update(propietario);
    } catch (Exception e) {
        throw new SaveUpdateException(e);
    }
}

From source file:app.datos.servicios.implementacion.ReservaServiceImpl.java

License:Open Source License

@Override
@Transactional(rollbackFor = PersistenciaException.class) //si falla hace rollback de la transaccin
public void modificarReserva(Reserva reserva) throws PersistenciaException {
    Session session = getSessionFactory().getCurrentSession();
    try {/* w  ww.  j  av a 2 s.  c  om*/
        session.update(reserva);
    } catch (Exception e) {
        throw new SaveUpdateException(e);
    }

}

From source file:app.datos.servicios.implementacion.VendedorServiceImpl.java

License:Open Source License

@Override
@Transactional(rollbackFor = PersistenciaException.class) //si falla hace rollback de la transaccin
public void modificarVendedor(Vendedor vendedor) throws PersistenciaException {
    Session session = getSessionFactory().getCurrentSession();
    try {/*from   w  ww.ja  va  2 s  . c  o m*/
        session.update(vendedor);
    } catch (Exception e) {
        throw new SaveUpdateException(e);
    }
}

From source file:app.Ejer1.java

public static void updateSeguro(Seguro seguro) {
    SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
    Session session = sessionFactory.openSession();

    seguro.setNombre("Edgar Modificado");

    session.beginTransaction();/*from   w w w .  j a  v a2s .c om*/
    session.update(seguro);
    session.getTransaction().commit();

    session.close();
}

From source file:app.Ejer2.java

public static void updateSeguro(SeguroAnotaciones seguro) {
    SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
    Session session = sessionFactory.openSession();

    seguro.setNombre("Edgar Modificado");

    session.beginTransaction();/* w w w. ja v  a  2  s  .co  m*/
    session.update(seguro);
    session.getTransaction().commit();

    session.close();
}

From source file:appcostal.model.DAO.java

public void actualizar(Object obj) {
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();//  w w  w  .  j av a 2 s. c  o m
    Transaction tx = se.beginTransaction();
    se.update(obj);
    tx.commit();
    se.close();
}

From source file:appHibernateSebastianLeonte.Main.java

public static void modificar() {
    SessionFactory session = SessionFactoryUtil.getSessionFactory();
    Session s = session.openSession();
    Transaction transaction = s.beginTransaction();
    System.out.println("Modificando");
    Vuelos vuelos = (Vuelos) s.load(Vuelos.class, (String) "AB-BY-4811");
    vuelos.setProcedencia("Hola");
    s.update(vuelos);
    s.save(vuelos);//from  ww w  .  j  av a 2  s. co  m
    transaction.commit();
    s.close();
    session.close();
}

From source file:appointment.businessobject.ManageCustomer.java

public Boolean updateCustomer(Long CustomerID, String fname, String lname) {
    Session session = factory.openSession();
    Transaction tx = null;//from  w  w w  .  j a v a2 s  .  c  o m
    try {
        tx = session.beginTransaction();
        Customer customer = (Customer) session.get(Customer.class, CustomerID);
        customer.setFirstName(fname);
        customer.setLastName(lname);
        session.update(customer);
        tx.commit();
        return true;
    } catch (HibernateException e) {
        if (tx != null) {
            tx.rollback();
        }
        e.printStackTrace();
        return false;
    } finally {
        session.close();
    }
}

From source file:ar.com.hibernate.dao.Dao.java

public void modificar(E entity) {

    Session session = null;
    Transaction transaction = null;/*w  w w. j  a va  2s  .co  m*/
    try {
        session = SessionManager.getSessionFactory().openSession();
        transaction = session.beginTransaction();
        // el metodo saveOrUpdate realiza automaticamente la operacion correcta
        session.update(entity);
        transaction.commit();

    } catch (HibernateException ex) {
        if (transaction != null) {
            transaction.rollback(); // Realiza un rollback si re realiza una sucesion de operaciones en la base y alguna no se cumple correctamente.
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
}

From source file:ar.edu.unju.fi.apu.dao.imp.mysql.PacienteDAOImp.java

@Override
public void modificarPaciente(Paciente paciente) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/* w w  w .j  ava 2 s .c o  m*/
    session.update(paciente);
    session.getTransaction().commit();
    session.close();
}