Java Code Examples for org.springframework.jdbc.datasource.ConnectionHolder

The following examples show how to use org.springframework.jdbc.datasource.ConnectionHolder. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   Source File: JpaTransactionManager.java    License: MIT License 6 votes vote down vote up
@Override
protected Object doGetTransaction() {
	JpaTransactionObject txObject = new JpaTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	EntityManagerHolder emHolder = (EntityManagerHolder)
			TransactionSynchronizationManager.getResource(obtainEntityManagerFactory());
	if (emHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound EntityManager [" + emHolder.getEntityManager() +
					"] for JPA transaction");
		}
		txObject.setEntityManagerHolder(emHolder, false);
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 2
Source Project: spring-analysis-note   Source File: StoredProcedureTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testAddInvoicesWithinTransaction() throws Exception {
	given(callableStatement.execute()).willReturn(false);
	given(callableStatement.getUpdateCount()).willReturn(-1);
	given(callableStatement.getObject(3)).willReturn(4);
	given(connection.prepareCall("{call " + AddInvoice.SQL + "(?, ?, ?)}")
			).willReturn(callableStatement);
	TransactionSynchronizationManager.bindResource(dataSource, new ConnectionHolder(connection));
	try {
		testAddInvoice(1106, 3);
		verify(callableStatement).setObject(1, 1106, Types.INTEGER);
		verify(callableStatement).setObject(2, 3, Types.INTEGER);
		verify(callableStatement).registerOutParameter(3, Types.INTEGER);
		verify(connection, never()).close();
	}
	finally {
		TransactionSynchronizationManager.unbindResource(dataSource);
		connection.close();
	}
}
 
Example 3
Source Project: java-technology-stack   Source File: JpaTransactionManager.java    License: MIT License 6 votes vote down vote up
@Override
protected Object doGetTransaction() {
	JpaTransactionObject txObject = new JpaTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	EntityManagerHolder emHolder = (EntityManagerHolder)
			TransactionSynchronizationManager.getResource(obtainEntityManagerFactory());
	if (emHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound EntityManager [" + emHolder.getEntityManager() +
					"] for JPA transaction");
		}
		txObject.setEntityManagerHolder(emHolder, false);
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 4
Source Project: java-technology-stack   Source File: StoredProcedureTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testAddInvoicesWithinTransaction() throws Exception {
	given(callableStatement.execute()).willReturn(false);
	given(callableStatement.getUpdateCount()).willReturn(-1);
	given(callableStatement.getObject(3)).willReturn(4);
	given(connection.prepareCall("{call " + AddInvoice.SQL + "(?, ?, ?)}")
			).willReturn(callableStatement);
	TransactionSynchronizationManager.bindResource(dataSource, new ConnectionHolder(connection));
	try {
		testAddInvoice(1106, 3);
		verify(callableStatement).setObject(1, 1106, Types.INTEGER);
		verify(callableStatement).setObject(2, 3, Types.INTEGER);
		verify(callableStatement).registerOutParameter(3, Types.INTEGER);
		verify(connection, never()).close();
	}
	finally {
		TransactionSynchronizationManager.unbindResource(dataSource);
		connection.close();
	}
}
 
Example 5
Source Project: lams   Source File: JpaTransactionManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Object doGetTransaction() {
	JpaTransactionObject txObject = new JpaTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	EntityManagerHolder emHolder = (EntityManagerHolder)
			TransactionSynchronizationManager.getResource(getEntityManagerFactory());
	if (emHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound EntityManager [" + emHolder.getEntityManager() +
					"] for JPA transaction");
		}
		txObject.setEntityManagerHolder(emHolder, false);
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 6
Source Project: lams   Source File: JdoTransactionManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Object doGetTransaction() {
	JdoTransactionObject txObject = new JdoTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	PersistenceManagerHolder pmHolder = (PersistenceManagerHolder)
			TransactionSynchronizationManager.getResource(getPersistenceManagerFactory());
	if (pmHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound PersistenceManager [" +
					pmHolder.getPersistenceManager() + "] for JDO transaction");
		}
		txObject.setPersistenceManagerHolder(pmHolder, false);
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 7
@Override
protected Object doGetTransaction() {
	JpaTransactionObject txObject = new JpaTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	EntityManagerHolder emHolder = (EntityManagerHolder)
			TransactionSynchronizationManager.getResource(getEntityManagerFactory());
	if (emHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound EntityManager [" + emHolder.getEntityManager() +
					"] for JPA transaction");
		}
		txObject.setEntityManagerHolder(emHolder, false);
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 8
@Override
protected Object doGetTransaction() {
	JdoTransactionObject txObject = new JdoTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	PersistenceManagerHolder pmHolder = (PersistenceManagerHolder)
			TransactionSynchronizationManager.getResource(getPersistenceManagerFactory());
	if (pmHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound PersistenceManager [" +
					pmHolder.getPersistenceManager() + "] for JDO transaction");
		}
		txObject.setPersistenceManagerHolder(pmHolder, false);
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 9
@Test
public void testAddInvoicesWithinTransaction() throws Exception {
	given(callableStatement.execute()).willReturn(false);
	given(callableStatement.getUpdateCount()).willReturn(-1);
	given(callableStatement.getObject(3)).willReturn(4);
	given(connection.prepareCall("{call " + AddInvoice.SQL + "(?, ?, ?)}")
			).willReturn(callableStatement);
	TransactionSynchronizationManager.bindResource(dataSource, new ConnectionHolder(connection));
	try {
		testAddInvoice(1106, 3);
		verify(callableStatement).setObject(1, 1106, Types.INTEGER);
		verify(callableStatement).setObject(2, 3, Types.INTEGER);
		verify(callableStatement).registerOutParameter(3, Types.INTEGER);
		verify(connection, never()).close();
	}
	finally {
		TransactionSynchronizationManager.unbindResource(dataSource);
		connection.close();
	}
}
 
Example 10
Source Project: gorm-hibernate5   Source File: HibernateDatastore.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addTenantForSchema(String schemaName) {
    addTenantForSchemaInternal(schemaName);
    registerAllEntitiesWithEnhancer();
    HibernateConnectionSource defaultConnectionSource = (HibernateConnectionSource) connectionSources.getDefaultConnectionSource();
    DataSource dataSource = defaultConnectionSource.getDataSource();
    if(dataSource instanceof TransactionAwareDataSourceProxy) {
        dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource();
    }
    Object existing = TransactionSynchronizationManager.getResource(dataSource);
    if(existing instanceof ConnectionHolder) {
        ConnectionHolder connectionHolder = (ConnectionHolder) existing;
        Connection connection = connectionHolder.getConnection();
        try {
            if(!connection.isClosed() && !connection.isReadOnly()) {
                schemaHandler.useDefaultSchema(connection);
            }
        } catch (SQLException e) {
            throw new DatastoreConfigurationException("Failed to reset to default schema: " + e.getMessage(), e);
        }
    }

}
 
Example 11
Source Project: effectivejava   Source File: StoredProcedureTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAddInvoicesWithinTransaction() throws Exception {
	given(callableStatement.execute()).willReturn(false);
	given(callableStatement.getUpdateCount()).willReturn(-1);
	given(callableStatement.getObject(3)).willReturn(4);
	given(connection.prepareCall("{call " + AddInvoice.SQL + "(?, ?, ?)}")
			).willReturn(callableStatement);
	TransactionSynchronizationManager.bindResource(dataSource, new ConnectionHolder(connection));
	try {
		testAddInvoice(1106, 3);
		verify(callableStatement).setObject(1, 1106, Types.INTEGER);
		verify(callableStatement).setObject(2, 3, Types.INTEGER);
		verify(callableStatement).registerOutParameter(3, Types.INTEGER);
		verify(connection, never()).close();
	}
	finally {
		TransactionSynchronizationManager.unbindResource(dataSource);
		connection.close();
	}
}
 
Example 12
Source Project: spring-analysis-note   Source File: HibernateTransactionManager.java    License: MIT License 5 votes vote down vote up
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionFactory sessionFactory = obtainSessionFactory();
	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" + sessionHolder.getSession() + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = sessionFactory.getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" + session + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 13
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionFactory sessionFactory = obtainSessionFactory();
	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" + sessionHolder.getSession() + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = sessionFactory.getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" + session + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 14
@Override
protected Connection getConnectionFromTransactionManager() {
    try {
        Connection result = transactionManager.getDataSource().getConnection();
        TransactionSynchronizationManager.bindResource(transactionManager.getDataSource(), new ConnectionHolder(result));
        return result;
    } catch (final SQLException ex) {
        throw new ShardingException("Could not open JDBC Connection before transaction", ex);
    }
}
 
Example 15
@Test
public void assertUnbindResource() {
    ConnectionHolder holder = mock(ConnectionHolder.class);
    Connection connection = mock(Connection.class);
    when(holder.getConnection()).thenReturn(connection);
    TransactionSynchronizationManager.bindResource(dataSource, holder);
    dataSourceTransactionManagerHandler.unbindResource();
    assertNull(TransactionSynchronizationManager.getResource(dataSource));
}
 
Example 16
Source Project: lams   Source File: OpenJpaDialect.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object createSavepoint() throws TransactionException {
	this.savepointCounter++;
	String savepointName = ConnectionHolder.SAVEPOINT_NAME_PREFIX + this.savepointCounter;
	this.entityManager.setSavepoint(savepointName);
	return savepointName;
}
 
Example 17
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" + sessionHolder.getSession() + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = this.sessionFactory.getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" + session + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 18
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" + sessionHolder.getSession() + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = this.sessionFactory.getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" + session + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 19
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" +
					SessionFactoryUtils.toString(sessionHolder.getSession()) + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = getSessionFactory().getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" +
						SessionFactoryUtils.toString(session) + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 20
Source Project: tcc-transaction   Source File: TXAspectProcessor.java    License: Apache License 2.0 5 votes vote down vote up
private void assertTransactional()throws Throwable{
    DataSource dataSource= dataSourceAdaptor.getDataSource();
    Assert.notNull(dataSource,"datasource can not empty");
    ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
    if (conHolder == null || conHolder.getConnectionHandle()==null || !conHolder.isSynchronizedWithTransaction()) {
        throw new DistributedTransactionException("transaction connection is null");
    }
}
 
Example 21
@Override
public Integer getTimeout() throws SQLException {
    ConnectionHolder holder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
    if (holder != null && holder.hasTimeout()) {
        return holder.getTimeToLiveInSeconds();
    }
    return null;
}
 
Example 22
Source Project: spring4-understanding   Source File: OpenJpaDialect.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object createSavepoint() throws TransactionException {
	this.savepointCounter++;
	String savepointName = ConnectionHolder.SAVEPOINT_NAME_PREFIX + this.savepointCounter;
	this.entityManager.setSavepoint(savepointName);
	return savepointName;
}
 
Example 23
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" +
					SessionFactoryUtils.toString(sessionHolder.getSession()) + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = getSessionFactory().getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" +
						SessionFactoryUtils.toString(session) + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 24
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" + sessionHolder.getSession() + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = this.sessionFactory.getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" + session + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 25
@Override
protected Object doGetTransaction() {
	HibernateTransactionObject txObject = new HibernateTransactionObject();
	txObject.setSavepointAllowed(isNestedTransactionAllowed());

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Found thread-bound Session [" + sessionHolder.getSession() + "] for Hibernate transaction");
		}
		txObject.setSessionHolder(sessionHolder);
	}
	else if (this.hibernateManagedSession) {
		try {
			Session session = this.sessionFactory.getCurrentSession();
			if (logger.isDebugEnabled()) {
				logger.debug("Found Hibernate-managed Session [" + session + "] for Spring-managed transaction");
			}
			txObject.setExistingSession(session);
		}
		catch (HibernateException ex) {
			throw new DataAccessResourceFailureException(
					"Could not obtain Hibernate-managed Session for Spring-managed transaction", ex);
		}
	}

	if (getDataSource() != null) {
		ConnectionHolder conHolder = (ConnectionHolder)
				TransactionSynchronizationManager.getResource(getDataSource());
		txObject.setConnectionHolder(conHolder);
	}

	return txObject;
}
 
Example 26
Source Project: galaxy   Source File: TXAspectProcessor.java    License: Apache License 2.0 5 votes vote down vote up
private void assertTransactional()throws Throwable{
    DataSource dataSource= dataSourceAdaptor.getDataSource();
    Assert.notNull(dataSource,"datasource can not empty");
    ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
    if (conHolder == null || conHolder.getConnectionHandle()==null || !conHolder.isSynchronizedWithTransaction()) {
        throw new DistributedTransactionException("transaction connection is null");
    }
}
 
Example 27
Source Project: syncope   Source File: OpenJpaDialect.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object createSavepoint() throws TransactionException {
    this.savepointCounter++;
    String savepointName = ConnectionHolder.SAVEPOINT_NAME_PREFIX + this.savepointCounter;
    this.entityManager.setSavepoint(savepointName);
    return savepointName;
}
 
Example 28
Source Project: spring-analysis-note   Source File: JpaTransactionManager.java    License: MIT License 4 votes vote down vote up
private SuspendedResourcesHolder(EntityManagerHolder emHolder, @Nullable ConnectionHolder conHolder) {
	this.entityManagerHolder = emHolder;
	this.connectionHolder = conHolder;
}
 
Example 29
Source Project: spring-analysis-note   Source File: JpaTransactionManager.java    License: MIT License 4 votes vote down vote up
@Nullable
private ConnectionHolder getConnectionHolder() {
	return this.connectionHolder;
}
 
Example 30
Source Project: spring-analysis-note   Source File: HibernateTransactionManager.java    License: MIT License 4 votes vote down vote up
private SuspendedResourcesHolder(SessionHolder sessionHolder, @Nullable ConnectionHolder conHolder) {
	this.sessionHolder = sessionHolder;
	this.connectionHolder = conHolder;
}