当前位置: 首页>>代码示例>>Java>>正文


Java TransactionStatus.ACTIVE属性代码示例

本文整理汇总了Java中org.hibernate.resource.transaction.spi.TransactionStatus.ACTIVE属性的典型用法代码示例。如果您正苦于以下问题:Java TransactionStatus.ACTIVE属性的具体用法?Java TransactionStatus.ACTIVE怎么用?Java TransactionStatus.ACTIVE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.hibernate.resource.transaction.spi.TransactionStatus的用法示例。


在下文中一共展示了TransactionStatus.ACTIVE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

@Sessional
@Override
public void render(WebSocketRegion region, @Nullable PageKey sourcePageKey) {
	if (dao.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE) {
		dao.doAfterCommit(new Runnable() {

			@Override
			public void run() {
				doRender(region, sourcePageKey);
			}
			
		});
	} else {
		doRender(region, sourcePageKey);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:16,代码来源:DefaultWebSocketManager.java

示例2: onSessionEnd

/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    Session hibSes = ses.attach(null);

    if (hibSes != null) {
        try {
            Transaction tx = hibSes.getTransaction();

            if (commit) {
                if (hibSes.isDirty())
                    hibSes.flush();

                if (tx.getStatus() == TransactionStatus.ACTIVE)
                    tx.commit();
            }
            else if (tx.getStatus().canRollback())
                tx.rollback();
        }
        catch (HibernateException e) {
            throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
        }
        finally {
            hibSes.close();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:CacheHibernateStoreSessionListener.java

示例3: afterTest

/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
    super.afterTest();

    Session s = store.session(null);

    if (s == null)
        return;

    try {
        s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName())
                .setFlushMode(FlushMode.ALWAYS).executeUpdate();

        Transaction hTx = s.getTransaction();

        if (hTx != null && hTx.getStatus() == TransactionStatus.ACTIVE)
            hTx.commit();
    }
    finally {
        s.close();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:CacheHibernateBlobStoreSelfTest.java

示例4: previewMerge

@Sessional
@Override
public MergePreview previewMerge(PullRequest request) {
	if (request.getMergeStrategy() != MergeStrategy.DO_NOT_MERGE) {
		MergePreview lastPreview = request.getLastMergePreview();
		if (request.isOpen() && !request.isMergeIntoTarget() 
				&& (lastPreview == null || lastPreview.isObsolete(request))) {
			int priority = RequestCycle.get() != null?UI_PREVIEW_PRIORITY:BACKEND_PREVIEW_PRIORITY;			
			if (dao.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE) {
				doAfterCommit(new Runnable() {

					@Override
					public void run() {
						batchWorkManager.submit(getMergePreviewer(request), new Prioritized(priority));
					}
					
				});
			} else {
				batchWorkManager.submit(getMergePreviewer(request), new Prioritized(priority));
			}
			return null;
		} else {
			return lastPreview;
		}
	} else {
		return null;
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:28,代码来源:DefaultPullRequestManager.java

示例5: checkAsync

@Sessional
protected void checkAsync(PullRequest request) {
	Long requestId = request.getId();
	Subject subject = SecurityUtils.getSubject();
	if (dao.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE) {
		doUnitOfWorkAsyncAfterCommit(newCheckStatusRunnable(requestId, subject));
	} else {
		unitOfWork.doAsync(newCheckStatusRunnable(requestId, subject));
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:10,代码来源:DefaultPullRequestManager.java

示例6: sendMailAsync

@Sessional
@Override
public void sendMailAsync(Collection<String> toList, String subject, String body) {
	if (dao.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE) {
		dao.doAsyncAfterCommit(newSendMailRunnable(toList, subject, body));
	} else {
		executorService.execute(newSendMailRunnable(toList, subject, body));
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:9,代码来源:DefaultMailManager.java

示例7: invoke

public Object invoke(MethodInvocation mi) throws Throwable {
	if (persistManager.getSessionFactory() != null) {
		unitOfWork.begin();
		try {
			Session session = unitOfWork.getSession();
			if (session.getTransaction().getStatus() == TransactionStatus.ACTIVE) {
				return mi.proceed();
			} else {
				Transaction tx = session.beginTransaction();
				FlushMode previousMode = session.getFlushMode();
				session.setFlushMode(FlushMode.COMMIT);
				try {
					Object result = mi.proceed();
					tx.commit();
					return result;
				} catch (Throwable t) {
					try {
						tx.rollback();
					} catch (Throwable t2) {
					}
					throw t;
				} finally {
					session.setFlushMode(previousMode);
				}
			}
			
		} finally {
			unitOfWork.end();
		}
	} else {
		return mi.proceed();
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:33,代码来源:TransactionInterceptor.java

示例8: search

public List<String> search(String productName){
    try{ if(sessionFactory.getCurrentSession().getTransaction().getStatus() != TransactionStatus.ACTIVE)
        sessionFactory.getCurrentSession().getTransaction().begin();
        Query query = sessionFactory.getCurrentSession().createQuery("select name from Product where name like :name");
        query.setString("name",productName + "%");
        System.out.println(query.list().toString());
        return query.list();
    }catch(Exception e){
        return null;
    }
}
 
开发者ID:TomirKlos,项目名称:Webstore,代码行数:11,代码来源:ProductRepositoryImpl.java

示例9: completeWorkflow

@Override
public void completeWorkflow() throws ProvisioningException {
	Session session = null;
	try {
		
		if (this.cfgMgr.getProvisioningEngine().getHibernateSessionFactory() != null) {
			session = this.cfgMgr.getProvisioningEngine().getHibernateSessionFactory().openSession();
			session.beginTransaction();
			DateTime now = new DateTime();
			Workflows wf = session.load(Workflows.class, this.id);
			wf.setCompleteTs(new Timestamp(now.getMillis()));
			session.save(wf);
			session.getTransaction().commit();
			
		}
	} finally {
		if (session != null) {
			
			if (session.getTransaction() != null && session.getTransaction().getStatus() == TransactionStatus.ACTIVE) {
				session.getTransaction().rollback();
			}
			
			session.close();
		}
	}
	
	
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:28,代码来源:WorkflowImpl.java

示例10: close

@Override
public void close() throws IOException {
    if (session.isOpen() && session.getTransaction().getStatus() == TransactionStatus.ACTIVE) {
        session.getTransaction().rollback();
        throw new IOException("Transaction not closed");
    }
}
 
开发者ID:yahoo,项目名称:elide,代码行数:7,代码来源:HibernateTransaction.java

示例11: end

/**
 * Ends hibernate session.
 *
 * @param ses Hibernate session.
 * @param tx Cache ongoing transaction.
 */
private void end(Session ses, Transaction tx) {
    // Commit only if there is no cache transaction,
    // otherwise sessionEnd() will do all required work.
    if (tx == null) {
        org.hibernate.Transaction hTx = ses.getTransaction();

        if (hTx != null && hTx.getStatus() == TransactionStatus.ACTIVE)
            hTx.commit();

        ses.close();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:CacheHibernateBlobStore.java

示例12: rollbackTransaction

private void rollbackTransaction(Session session, UnitOfWork uow) {
    if (uow.transactional()) {
        Transaction txn = session.getTransaction();
        if (txn != null && session.getTransaction().getStatus() != TransactionStatus.ACTIVE) {
            txn.rollback();
        }
    }

}
 
开发者ID:robeio,项目名称:robe,代码行数:9,代码来源:WrapperServlet.java

示例13: commitTransaction

private void commitTransaction(Session session, UnitOfWork uow) {
    if (uow.transactional()) {
        Transaction txn = session.getTransaction();
        if (txn != null && session.getTransaction().getStatus() != TransactionStatus.ACTIVE) {
            txn.commit();
        }
    }

}
 
开发者ID:robeio,项目名称:robe,代码行数:9,代码来源:WrapperServlet.java

示例14: addAction

void addAction(SessionEventListener... listeners) throws HibernateException
{
	final Session session = sessionProvider.get();

	if (session.getTransaction().getStatus() != TransactionStatus.ACTIVE)
		throw new IllegalStateException("Cannot add transaction action with no active transaction!");

	session.addEventListeners(listeners);
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:9,代码来源:TransactionHelper.java

示例15: hasHibernateManagedTransaction

public boolean hasHibernateManagedTransaction() {
	return (this.sessionHolder != null &&
			this.sessionHolder.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:HibernateTransactionManager.java


注:本文中的org.hibernate.resource.transaction.spi.TransactionStatus.ACTIVE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。