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:com.siemens.scr.avt.ad.api.impl.DefaultADFacadeImpl.java

License:Open Source License

@Override
public Set<ImageAnnotation> retrieveAnnotationsOf(GeneralImage image) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    image = (GeneralImage) session.merge(image);
    Set<ImageAnnotation> result = image.getAnnotations();
    ((SessionImplementor) session).initializeCollection((PersistentCollection) result, false);
    session.close();//  w  w w  . j  a v a2 s . c om
    return result;
}

From source file:com.siemens.scr.avt.ad.api.impl.DefaultADFacadeImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from  ww  w  . j  a  v a  2s . co  m
public Set<GeneralImage> retrieveImagesOf(GeneralSeries series) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    series = (GeneralSeries) session.merge(series);
    Set<GeneralImage> result = series.getImages();
    ((SessionImplementor) session).initializeCollection((PersistentCollection) result, false);
    session.close();
    return result;
}

From source file:com.siemens.scr.avt.ad.api.impl.DefaultADFacadeImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*  w  ww.  j a  v  a2s .  c o m*/
public Set<GeneralSeries> retrieveSeriesOf(GeneralStudy study) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    study = (GeneralStudy) session.merge(study);
    Set<GeneralSeries> result = study.getSeries();
    ((SessionImplementor) session).initializeCollection((PersistentCollection) result, false);
    session.close();
    return result;
}

From source file:com.siemens.scr.avt.ad.api.impl.DefaultADFacadeImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from   ww w  .j a v  a2 s.  c om*/
public Set<GeneralStudy> retrieveStudiesOf(Patient patient) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    patient = (Patient) session.merge(patient);
    Set<GeneralStudy> result = patient.getStudies();
    ((SessionImplementor) session).initializeCollection((PersistentCollection) result, false);
    session.close();
    return result;
}

From source file:com.smi.dao.DashboardStatDaoImpl.java

License:Apache License

@Override
@Transactional
public void edit(DashboardStat dashboard) {
    Session session = sessionFactory.getCurrentSession();
    session.merge(dashboard);
}

From source file:com.smi.dao.DashboardUserDaoImpl.java

License:Apache License

@Override
@Transactional
public void edit(DashboardUser dashboard) {
    Session session = sessionFactory.getCurrentSession();
    session.merge(dashboard);
}

From source file:com.smi.dao.RessourceDaoImpl.java

License:Apache License

@Override
@Transactional
public void edit(Ressources ressource) {
    Session session = sessionFactory.getCurrentSession();
    session.merge(ressource);
}

From source file:com.smi.dao.ServiceDaoImpl.java

License:Apache License

@Override
@Transactional
public void edit(Service service) {
    Session session = sessionFactory.getCurrentSession();
    session.merge(service);
}

From source file:com.smi.travel.datalayer.dao.impl.CustomerImpl.java

@Override
public int updateCustomer(Customer customer) {
    int result = 0;
    try {/*  w  ww . j a  v  a 2s. c  o m*/
        Session session = this.sessionFactory.openSession();
        transaction = session.beginTransaction();
        session.merge(customer);
        transaction.commit();
        session.close();
        result = 1;
    } catch (Exception ex) {
        ex.printStackTrace();
        result = 0;
    }
    return result;
}

From source file:com.smi.travel.datalayer.dao.impl.MasterImpl.java

@Override
public int updateBooking(Master master, Passenger passenger) {
    int result = 0;
    try {//w w  w .j a  va 2 s.c o m
        Session session = this.getSessionFactory().openSession();
        setTransaction(session.beginTransaction());
        //save customer
        if (master.getCustomer() != null) {
            if (master.getCustomer().getId() == null) {
                System.out.println("save master");
                Customer cus = master.getCustomer();
                session.save(master.getCustomer());
            } else {
                System.out.println("update master");
                session.update(master.getCustomer());
            }
        }
        System.out.println("master id :" + master.getId());
        session.merge(master);

        //save passenger

        if (passenger.getId() == null) {
            System.out.println("save passenger");
            session.save(passenger);
        } else {
            System.out.println("update passenger : " + passenger.getId());
            // System.out.println("update customer id : " +;
            passenger.setCustomer(master.getCustomer());
            session.merge(passenger);
        }

        getTransaction().commit();
        session.close();
        this.getSessionFactory().close();
        result = 1;
    } catch (Exception ex) {
        getTransaction().rollback();
        ex.printStackTrace();
        result = 0;
    }
    return result;
}