Example usage for org.hibernate Session refresh

List of usage examples for org.hibernate Session refresh

Introduction

In this page you can find the example usage for org.hibernate Session refresh.

Prototype

void refresh(Object object, LockOptions lockOptions);

Source Link

Document

Re-read the state of the given instance from the underlying database, with the given LockMode.

Usage

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

License:Apache License

public void refresh(final Object entity, final LockMode lockMode) throws Exception {
    doHibernate(new HibernateCallback() {
        public Object execute(Session session) throws HibernateException {
            if (lockMode != null) {
                session.refresh(entity, lockMode);
            } else {
                session.refresh(entity);
            }/*from   w w w  . j  a  v  a2 s .  c o m*/
            return null;
        }
    });
}

From source file:com.npower.dm.hibernate.management.ProvisionJobManagementBeanImpl.java

License:Open Source License

public void update(ProvisionJob job) throws DMException {
    try {//w  w w . j a  v  a 2s.co  m
        Session session = this.getHibernateSession();
        job.setLastUpdatedTime(new Date());
        session.saveOrUpdate(job);
        session.flush();
        session.refresh(job, LockMode.UPGRADE);
        //session.refresh(job, LockMode.UPGRADE);

        // Update all of status related with the job.
        String newState = job.getState();
        this.updateJobState(job.getID(), newState);
    } catch (HibernateException e) {
        throw new DMException(e);
    }
}

From source file:org.openebiz.dao.common.cac.RoadTransportTypeDAOImpl.java

public void delete(RoadTransportType value) {
    Session session = getSession();
    session.refresh(value, LockMode.UPGRADE);
    session.delete(value);/*from  ww w .j  av a2 s  .  co  m*/
    if (log.isDebugEnabled())
        log.debug("deleting document: " + value);
}

From source file:org.openebiz.dao.common.cac.RoadTransportTypeDAOImpl.java

public void delete(Long id) {
    RoadTransportType value = getById(id);
    Session session = getSession();
    if (value != null) {
        session.refresh(value, LockMode.UPGRADE);
        session.delete(value);/*from  www.j a v  a2  s. co  m*/
        if (log.isDebugEnabled())
            log.debug("deleting document: " + value + " by ID:" + id);
    }
}

From source file:org.openebiz.dao.common.cbc.LicensePlateIDTypeDAOImpl.java

License:Open Source License

public void delete(LicensePlateIDType value) {
    Session session = getSession();
    session.refresh(value, LockMode.UPGRADE);
    session.delete(value);//from   w w  w.j  a  v  a2 s .co m
    if (log.isDebugEnabled())
        log.debug("deleting document: " + value);
}

From source file:org.openebiz.dao.common.cbc.LicensePlateIDTypeDAOImpl.java

License:Open Source License

public void delete(Long id) {
    LicensePlateIDType value = getById(id);
    Session session = getSession();
    if (value != null) {
        session.refresh(value, LockMode.UPGRADE);
        session.delete(value);//from   w  ww  .  j a v  a2  s.  c  om
        if (log.isDebugEnabled())
            log.debug("deleting document: " + value + " by ID:" + id);
    }
}

From source file:org.opengoss.dao.hibernate.DataAccessor.java

License:Apache License

public void refresh(final Object entity, final LockMode lockMode) throws DaoException {
    execute(new IAccessorCallback() {
        public Object call(Session session) throws HibernateException {
            if (lockMode != null) {
                session.refresh(entity, lockMode);
            } else {
                session.refresh(entity);
            }//  w  w  w.j a v a2  s  .c  o m
            return null;
        }
    });
}

From source file:org.springframework.orm.hibernate3.HibernateTemplate.java

License:Apache License

@Override
public void refresh(final Object entity, final LockMode lockMode) throws DataAccessException {
    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override//from  w w w.j av a2  s. c o m
        public Object doInHibernate(Session session) throws HibernateException {
            if (lockMode != null) {
                session.refresh(entity, lockMode);
            } else {
                session.refresh(entity);
            }
            return null;
        }
    });
}

From source file:org.springframework.orm.hibernate3.StatelessHibernateTemplate.java

License:Apache License

public void refresh(final Object entity, final LockMode lockMode) throws DataAccessException {
    execute(new CombinedHibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException {
            if (lockMode != null) {
                session.refresh(entity, lockMode);
            } else {
                session.refresh(entity);
            }/*from   ww w .  j  a v  a 2  s .  c  o m*/
            return null;
        }

        public Object doInHibernate(StatelessSession session) throws HibernateException {
            if (lockMode != null) {
                session.refresh(entity, lockMode);
            } else {
                session.refresh(entity);
            }
            return null;
        }
    }, true);
}

From source file:org.springframework.orm.hibernate4.HibernateTemplate.java

License:Apache License

@Override
public void refresh(final Object entity, final LockMode lockMode) throws DataAccessException {
    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override/*from w  w  w  .  java2  s. c  o  m*/
        public Object doInHibernate(Session session) throws HibernateException {
            if (lockMode != null) {
                session.refresh(entity, new LockOptions(lockMode));
            } else {
                session.refresh(entity);
            }
            return null;
        }
    });
}