当前位置: 首页>>代码示例>>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;未经允许,请勿转载。