Java Code Examples for org.apache.openjpa.persistence.jdbc.IsolationLevel#fromConnectionConstant()

The following examples show how to use org.apache.openjpa.persistence.jdbc.IsolationLevel#fromConnectionConstant() . 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 File: OpenJpaDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition)
		throws PersistenceException, SQLException, TransactionException {

	OpenJPAEntityManager openJpaEntityManager = getOpenJPAEntityManager(entityManager);

	if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
		// Pass custom isolation level on to OpenJPA's JDBCFetchPlan configuration
		FetchPlan fetchPlan = openJpaEntityManager.getFetchPlan();
		if (fetchPlan instanceof JDBCFetchPlan) {
			IsolationLevel isolation = IsolationLevel.fromConnectionConstant(definition.getIsolationLevel());
			((JDBCFetchPlan) fetchPlan).setIsolation(isolation);
		}
	}

	entityManager.getTransaction().begin();

	if (!definition.isReadOnly()) {
		// Like with EclipseLink, make sure to start the logic transaction early so that other
		// participants using the connection (such as JdbcTemplate) run in a transaction.
		openJpaEntityManager.beginStore();
	}

	// Custom implementation for OpenJPA savepoint handling
	return new OpenJpaTransactionData(openJpaEntityManager);
}
 
Example 2
Source File: OpenJpaDialect.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition)
		throws PersistenceException, SQLException, TransactionException {

	OpenJPAEntityManager openJpaEntityManager = getOpenJPAEntityManager(entityManager);

	if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
		// Pass custom isolation level on to OpenJPA's JDBCFetchPlan configuration
		FetchPlan fetchPlan = openJpaEntityManager.getFetchPlan();
		if (fetchPlan instanceof JDBCFetchPlan) {
			IsolationLevel isolation = IsolationLevel.fromConnectionConstant(definition.getIsolationLevel());
			((JDBCFetchPlan) fetchPlan).setIsolation(isolation);
		}
	}

	entityManager.getTransaction().begin();

	if (!definition.isReadOnly()) {
		// Like with EclipseLink, make sure to start the logic transaction early so that other
		// participants using the connection (such as JdbcTemplate) run in a transaction.
		openJpaEntityManager.beginStore();
	}

	// Custom implementation for OpenJPA savepoint handling
	return new OpenJpaTransactionData(openJpaEntityManager);
}
 
Example 3
Source File: OpenJpaDialect.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public Object beginTransaction(final EntityManager entityManager, final TransactionDefinition definition)
        throws PersistenceException, SQLException, TransactionException {

    OpenJPAEntityManager openJpaEntityManager = getOpenJPAEntityManager(entityManager);

    if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
        // Pass custom isolation level on to OpenJPA's JDBCFetchPlan configuration
        FetchPlan fetchPlan = openJpaEntityManager.getFetchPlan();
        if (fetchPlan instanceof JDBCFetchPlan) {
            IsolationLevel isolation = IsolationLevel.fromConnectionConstant(definition.getIsolationLevel());
            ((JDBCFetchPlan) fetchPlan).setIsolation(isolation);
        }
    }

    entityManager.getTransaction().begin();

    if (!definition.isReadOnly()) {
        // Like with EclipseLink, make sure to start the logic transaction early so that other
        // participants using the connection (such as JdbcTemplate) run in a transaction.
        openJpaEntityManager.beginStore();
    }

    // Custom implementation for OpenJPA savepoint handling
    return new OpenJpaTransactionData(openJpaEntityManager);
}