Java Code Examples for org.hibernate.Session.refresh()

The following are Jave code examples for showing how to use refresh() of the org.hibernate.Session class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OSWf-OSWorkflow-fork   File: HibernateStore.java   View Source Code Vote up 6 votes
public void moveToHistory(Step step, int actionId, Date finishDate, String status, String actor) throws WorkflowStoreException {

        Session session = null;
        
        try {
            
            session = sessionFactory.openSession();
            session.refresh(step);

            super.markFinished(step, actionId, finishDate, status, actor);
            update(session, step);

            HibernateStep currentStep = (HibernateStep)step;
            HibernateStep historyStep = new HibernateHistoryStep(currentStep);
            HibernateProcessInstance entry = currentStep.getEntry();

            entry.removeCurrentStep(currentStep);
            entry.addHistoryStep(historyStep);

            // Session transaction managed by the delete, save and update DAO methods
            delete(session, currentStep);
            save(session, historyStep);
            update(session, entry);
       
            if(logger.isDebugEnabled()) {
                logger.debug(historyStep.toString());
                logger.debug(entry.toString());
            }
       
        } catch(HibernateException hibernateException) {
            throw new WorkflowStoreException(hibernateException);
        } finally {

            if (session != null)
                session.close();
        }
        
        // Logging the results of this action

    }
 
Example 2
Project: tinyshop8   File: GoodsDAOImpl.java   View Source Code Vote up 5 votes
/**
 * 新增商品信息
 *
 * @param goods8     商品实体类
 * @param goodsType8 商品类型实体类
 * @return 返回新增具体类
 */
@Override
public FrameWorkDSCResult addGoods(final Goods8JPA goods8,
                                   final GoodsType8JPA goodsType8)
{
    FrameWorkDSCResult result = new FrameWorkDSCResult();

    try
    {
        setSession(null);
        Session session = SessionBasic.session;

        //User8JPA user = goods8.getUser8JPA();
        //user.getGoods8JPASet().add(goods8);
        //goods8.setUser8JPA(user);
        //goods8.setGoodsType(goodsType8);
        //goodsType8.getGoods8JPASet().add(goods8);

        session.merge(goods8);
        //更新商品类型信息
        session.refresh(goodsType8);
        //session.refresh(user);

        getTransaction().commit();
        result.setDaoFlag(true);
    }
    catch (Exception ex)
    {
        result.setDaoFlag(false);
        printStackTrace(ex);
        result.setDaoException(ex);
    }
    finally
    {
        return result;
    }
}
 
Example 3
Project: Planchester   File: PersistanceFacade.java   View Source Code Vote up 5 votes
public T put(T obj) {
    Session session = DatabaseConnectionHandler.getInstance().beginTransaction();
    session.saveOrUpdate(obj);
    session.flush();
    session.refresh(obj);
    DatabaseConnectionHandler.getInstance().commitTransaction();
    return obj;
}
 
Example 4
Project: unitimes   File: _BaseRootDAO.java   View Source Code Vote up 2 votes
/**
 * Re-read the state of the given instance from the underlying database. It is inadvisable to use this to implement
 * long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.
 */
public void refresh(T obj, Session s) {
	s.refresh(obj);
}