當前位置: 首頁>>代碼示例>>Java>>正文


Java DataSourceUtils.resetConnectionAfterTransaction方法代碼示例

本文整理匯總了Java中org.springframework.jdbc.datasource.DataSourceUtils.resetConnectionAfterTransaction方法的典型用法代碼示例。如果您正苦於以下問題:Java DataSourceUtils.resetConnectionAfterTransaction方法的具體用法?Java DataSourceUtils.resetConnectionAfterTransaction怎麽用?Java DataSourceUtils.resetConnectionAfterTransaction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.jdbc.datasource.DataSourceUtils的用法示例。


在下文中一共展示了DataSourceUtils.resetConnectionAfterTransaction方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resetSessionState

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
public void resetSessionState() {
	if (this.previousFlushMode != null) {
		this.session.setFlushMode(this.previousFlushMode);
	}
	if (this.preparedCon != null && this.session.isConnected()) {
		Connection conToReset = HibernateConnectionHandle.doGetConnection(this.session);
		if (conToReset != this.preparedCon) {
			LogFactory.getLog(HibernateJpaDialect.class).warn(
					"JDBC Connection to reset not identical to originally prepared Connection - please " +
					"make sure to use connection release mode ON_CLOSE (the default) and to run against " +
					"Hibernate 4.2+ (or switch HibernateJpaDialect's prepareConnection flag to false");
		}
		DataSourceUtils.resetConnectionAfterTransaction(conToReset, this.previousIsolationLevel);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:16,代碼來源:HibernateJpaDialect.java

示例2: doCleanupAfterCompletion

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
@Override
protected void doCleanupAfterCompletion(Object transaction) {
	DataSourceTransactionObject txObject = (DataSourceTransactionObject) transaction;

	// Remove the connection holder from the thread, if exposed.
	if (txObject.isNewConnectionHolder()) {
		TransactionSynchronizationManager.unbindResource(this.dataSource);
	}

	// Reset connection.
	Connection con = txObject.getConnectionHolder().getConnection();
	try {
		if (txObject.isMustRestoreAutoCommit()) {
			con.setAutoCommit(true);
		}
		DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
	}
	catch (Throwable ex) {
		logger.debug("Could not reset JDBC Connection after transaction", ex);
	}

	if (txObject.isNewConnectionHolder()) {
		if (logger.isDebugEnabled()) {
			logger.debug("Releasing JDBC Connection [" + con + "] after transaction");
		}
		DataSourceUtils.releaseConnection(con, this.dataSource);
	}

	txObject.getConnectionHolder().clear();
}
 
開發者ID:gsgsdtc,項目名稱:ldtm,代碼行數:31,代碼來源:LdtmDataSourceTransactionManager.java

示例3: doCleanupAfterCompletion

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
@Override
protected void doCleanupAfterCompletion(Object transaction) {
	HibernateTransactionObject txObject = (HibernateTransactionObject) transaction;

	// Remove the session holder from the thread.
	if (txObject.isNewSessionHolder()) {
		TransactionSynchronizationManager.unbindResource(getSessionFactory());
	}

	// Remove the JDBC connection holder from the thread, if exposed.
	if (getDataSource() != null) {
		TransactionSynchronizationManager.unbindResource(getDataSource());
	}

	Session session = txObject.getSessionHolder().getSession();
	if (this.prepareConnection && session.isConnected() && isSameConnectionForEntireSession(session)) {
		// We're running with connection release mode "on_close": We're able to reset
		// the isolation level and/or read-only flag of the JDBC Connection here.
		// Else, we need to rely on the connection pool to perform proper cleanup.
		try {
			Connection con = ((SessionImplementor) session).connection();
			DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
		}
		catch (HibernateException ex) {
			logger.debug("Could not access JDBC Connection of Hibernate Session", ex);
		}
	}

	if (txObject.isNewSession()) {
		if (logger.isDebugEnabled()) {
			logger.debug("Closing Hibernate Session [" + session + "] after transaction");
		}
		SessionFactoryUtils.closeSession(session);
	}
	else {
		if (logger.isDebugEnabled()) {
			logger.debug("Not closing pre-bound Hibernate Session [" + session + "] after transaction");
		}
		if (txObject.getSessionHolder().getPreviousFlushMode() != null) {
			session.setFlushMode(txObject.getSessionHolder().getPreviousFlushMode());
		}
		if (!this.hibernateManagedSession) {
			session.disconnect();
		}
	}
	txObject.getSessionHolder().clear();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:48,代碼來源:HibernateTransactionManager.java

示例4: doCleanupAfterCompletion

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
@Override
@SuppressWarnings("deprecation")
protected void doCleanupAfterCompletion(Object transaction) {
	HibernateTransactionObject txObject = (HibernateTransactionObject) transaction;

	// Remove the session holder from the thread.
	if (txObject.isNewSessionHolder()) {
		TransactionSynchronizationManager.unbindResource(getSessionFactory());
	}

	// Remove the JDBC connection holder from the thread, if exposed.
	if (getDataSource() != null) {
		TransactionSynchronizationManager.unbindResource(getDataSource());
	}

	Session session = txObject.getSessionHolder().getSession();
	if (this.prepareConnection && session.isConnected() && isSameConnectionForEntireSession(session)) {
		// We're running with connection release mode "on_close": We're able to reset
		// the isolation level and/or read-only flag of the JDBC Connection here.
		// Else, we need to rely on the connection pool to perform proper cleanup.
		try {
			Connection con = session.connection();
			DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
		}
		catch (HibernateException ex) {
			logger.debug("Could not access JDBC Connection of Hibernate Session", ex);
		}
	}

	if (txObject.isNewSession()) {
		if (logger.isDebugEnabled()) {
			logger.debug("Closing Hibernate Session [" + SessionFactoryUtils.toString(session) +
					"] after transaction");
		}
		SessionFactoryUtils.closeSessionOrRegisterDeferredClose(session, getSessionFactory());
	}
	else {
		if (logger.isDebugEnabled()) {
			logger.debug("Not closing pre-bound Hibernate Session [" +
					SessionFactoryUtils.toString(session) + "] after transaction");
		}
		if (txObject.getSessionHolder().getPreviousFlushMode() != null) {
			session.setFlushMode(txObject.getSessionHolder().getPreviousFlushMode());
		}
		if (!this.hibernateManagedSession) {
			session.disconnect();
		}
	}
	txObject.getSessionHolder().clear();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:51,代碼來源:HibernateTransactionManager.java

示例5: resetIsolationLevel

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
public void resetIsolationLevel() {
	if (this.previousIsolationLevel != null) {
		DataSourceUtils.resetConnectionAfterTransaction(connection,
				previousIsolationLevel);
	}
}
 
開發者ID:h819,項目名稱:spring-boot,代碼行數:7,代碼來源:CustomHibernateJpaDialect.java

示例6: resetIsolationLevel

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
public void resetIsolationLevel() {
    if (this.previousIsolationLevel != null) {
        DataSourceUtils.resetConnectionAfterTransaction(connection,
                previousIsolationLevel);
    }
}
 
開發者ID:przodownikR1,項目名稱:springJpaKata,代碼行數:7,代碼來源:CustomHibernateJpaDialect.java

示例7: reset

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
public void reset() {
    DataSourceUtils.resetConnectionAfterTransaction(connection, originalIsolation);
}
 
開發者ID:subes,項目名稱:invesdwin-context-persistence,代碼行數:4,代碼來源:HibernateExtendedJpaDialect.java

示例8: doCleanupAfterCompletion

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
@Override
protected void doCleanupAfterCompletion(Object transaction) {
	HibernateTransactionObject txObject = (HibernateTransactionObject) transaction;

	// Remove the session holder from the thread.
	if (txObject.isNewSessionHolder()) {
		TransactionSynchronizationManager.unbindResource(getSessionFactory());
	}

	// Remove the JDBC connection holder from the thread, if exposed.
	if (getDataSource() != null) {
		TransactionSynchronizationManager.unbindResource(getDataSource());
	}

	Session session = txObject.getSessionHolder().getSession();
	if (this.prepareConnection && session.isConnected() && isSameConnectionForEntireSession(session)) {
		// We're running with connection release mode "on_close": We're able to reset
		// the isolation level and/or read-only flag of the JDBC Connection here.
		// Else, we need to rely on the connection pool to perform proper cleanup.
		try {
			Connection con = session.connection();
			DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
		}
		catch (HibernateException ex) {
			logger.debug("Could not access JDBC Connection of Hibernate Session", ex);
		}
	}

	if (txObject.isNewSession()) {
		if (logger.isDebugEnabled()) {
			logger.debug("Closing Hibernate Session [" + SessionFactoryUtils.toString(session) +
					"] after transaction");
		}
		SessionFactoryUtils.closeSessionOrRegisterDeferredClose(session, getSessionFactory());
	}
	else {
		if (logger.isDebugEnabled()) {
			logger.debug("Not closing pre-bound Hibernate Session [" +
					SessionFactoryUtils.toString(session) + "] after transaction");
		}
		if (txObject.getSessionHolder().getPreviousFlushMode() != null) {
			session.setFlushMode(txObject.getSessionHolder().getPreviousFlushMode());
		}
		if (!this.hibernateManagedSession) {
			session.disconnect();
		}
	}
	txObject.getSessionHolder().clear();
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:50,代碼來源:HibernateTransactionManager.java

示例9: resetIsolationLevel

import org.springframework.jdbc.datasource.DataSourceUtils; //導入方法依賴的package包/類
public void resetIsolationLevel() {
  DataSourceUtils.resetConnectionAfterTransaction(connection, previousIsolationLevel);
}
 
開發者ID:BandwidthOnDemand,項目名稱:bandwidth-on-demand,代碼行數:4,代碼來源:HibernateJpaDialectWithTransactionIsolationSupport.java


注:本文中的org.springframework.jdbc.datasource.DataSourceUtils.resetConnectionAfterTransaction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。