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.hyron.poscafe.dao.PayTypeParamDaoImpl.java

License:Open Source License

@Override
public PayTypeParam merge(PayTypeParam detachedInstance, Session session) throws HibernateException {
    log.debug("merging PayTypeParam instance");
    try {//  w  ww  .  j  a v a  2s  . c o m
        PayTypeParam result = (PayTypeParam) session.merge(detachedInstance);
        log.debug("merge successful");
        return result;
    } catch (RuntimeException re) {
        log.error("merge failed", re);
        throw re;
    }
}

From source file:com.hyron.poscafe.dao.PosParamDaoImpl.java

License:Open Source License

@Override
public PosParam merge(PosParam detachedInstance, Session session) throws HibernateException {
    log.debug("merging PosParam instance");
    try {//from  ww  w  . j ava  2 s. c  o m
        PosParam result = (PosParam) session.merge(detachedInstance);
        log.debug("merge successful");
        return result;
    } catch (RuntimeException re) {
        log.error("merge failed", re);
        throw re;
    }
}

From source file:com.hyron.poscafe.dao.SaleItemDaoImpl.java

License:Open Source License

@Override
public SaleItem merge(SaleItem detachedInstance, Session session) throws HibernateException {
    log.debug("merging SaleItem instance");
    try {/*from   w  w w. j a  va 2  s . c  om*/
        SaleItem result = (SaleItem) session.merge(detachedInstance);
        log.debug("merge successful");
        return result;
    } catch (RuntimeException re) {
        log.error("merge failed", re);
        throw re;
    }
}

From source file:com.hyron.poscafe.dao.SaleItemDiscDaoImpl.java

License:Open Source License

@Override
public SaleItemDisc merge(SaleItemDisc detachedInstance, Session session) throws HibernateException {
    log.debug("merging SellItemDisc instance");
    try {/* w  w  w . j a v a2 s . c  om*/
        SaleItemDisc result = (SaleItemDisc) session.merge(detachedInstance);
        log.debug("merge successful");
        return result;
    } catch (RuntimeException re) {
        log.error("merge failed", re);
        throw re;
    }
}

From source file:com.hyron.poscafe.dao.TransDaoImpl.java

License:Open Source License

@Override
public Trans merge(Trans detachedInstance, Session session) throws HibernateException {
    log.debug("merging Trans instance");
    try {//from   w w w  .j  a v a 2s  .c  om
        Trans result = (Trans) session.merge(detachedInstance);
        log.debug("merge successful");
        return result;
    } catch (RuntimeException re) {
        log.error("merge failed", re);
        throw re;
    }
}

From source file:com.hyzy.core.orm.hibernate.HibernateDao.java

License:Apache License

/**
 * ??//from ww  w.j  av  a  2 s.c  om
 * @param lsit
 * @return
 * @throws SQLException 
 */
@Transactional
public void saveOrupdatBatch(List<Object> list) {

    int batchSize = 100;
    if (list == null || list.isEmpty())
        return;
    Session session = null;
    Transaction tx = null;
    try {
        session = getSessionFactory().openSession();
        tx = session.getTransaction();
        tx.begin();
        for (int i = 0; i < list.size(); i++) {
            session.merge((list.get(i)));
            if (i % batchSize == 0) {
                session.flush();
                session.clear();
            }
        }
        tx.commit();
    } catch (Exception e) {
        e.printStackTrace();
        tx.rollback();
    } finally {
        if (null != tx) {
            tx = null;
        }
        if (null != session) {
            session = null;
        }
    }
}

From source file:com.idega.bedework.bussiness.impl.BedeworkEventsServiceBean.java

@Override
public boolean updateEvent(User user, EventInfo event) {
    if (user == null || event == null) {
        return Boolean.FALSE;
    }/*from w  ww.j  a  v  a  2  s . c  o m*/

    BedeworkAPI bwAPI = new BedeworkAPI(user);
    EventsI eventsHandler = bwAPI.getEventsHandler();
    if (eventsHandler == null) {
        return Boolean.FALSE;
    }

    Session session = SessionFactoryUtil.getSession();
    if (session != null) {
        session.merge(event.getEvent());
    }

    try {
        eventsHandler.update(event, Boolean.FALSE);
    } catch (CalFacadeException e) {
        getLogger().log(Level.WARNING, "Failed to update event", e);
        return Boolean.FALSE;
    } finally {
        session.close();
        bwAPI.closeBedeworkAPI();
    }

    return Boolean.TRUE;
}

From source file:com.idega.bedework.data.BedeworkCalendarEntry.java

@Override
public String getDescription() {
    if (getEntry() == null) {
        return null;
    }/*from   w ww . ja  v a2  s .co  m*/

    Session session = SessionFactoryUtil.getSession();
    if (session == null) {
        return null;
    }

    session.merge(getEntry());
    String description = getEntry().getDescription();
    session.close();
    return description;
}

From source file:com.imos.hibernate.HibernateTest.java

private static void update(final Session session, PersonDetails ud) {
    session.beginTransaction();/*from ww w.ja  va  2 s  . c  o m*/
    ud.setUpdatedTime(new Date());
    session.merge(ud);
    session.getTransaction().commit();
}

From source file:com.jdon.persistence.hibernate.HibernateTemplate.java

License:Apache License

public Object merge(final Object entity) throws Exception {
    return doHibernate(new HibernateCallback() {
        public Object execute(Session session) throws HibernateException {
            return session.merge(entity);
        }/*  w w  w.ja v  a  2  s  . c  o  m*/
    });
}