Example usage for org.springframework.transaction TransactionDefinition ISOLATION_READ_COMMITTED

List of usage examples for org.springframework.transaction TransactionDefinition ISOLATION_READ_COMMITTED

Introduction

In this page you can find the example usage for org.springframework.transaction TransactionDefinition ISOLATION_READ_COMMITTED.

Prototype

int ISOLATION_READ_COMMITTED

To view the source code for org.springframework.transaction TransactionDefinition ISOLATION_READ_COMMITTED.

Click Source Link

Document

Indicates that dirty reads are prevented; non-repeatable reads and phantom reads can occur.

Usage

From source file:net.cpollet.jixture.tests.integration.hibernate3.BaseTestDatabaseTestSupport.java

private void executeInNewTransaction(TransactionCallback transactionCallback) {
    TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
    transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    transactionTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);

    transactionTemplate.execute(transactionCallback);
}

From source file:fi.hsl.parkandride.core.service.PredictionService.java

private void doUpdatePredictions() {
    log.info("Updating predictions");
    TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    txTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED); // TODO: set in Core/JdbcConfiguration
    txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);

    for (Long predictorId : findPredictorsNeedingUpdate()) {
        try {//from ww w  . java 2s  .c o m
            txTemplate.execute(tx -> {
                updatePredictor(predictorId);
                log.debug("Updating predictor {} done", predictorId);
                return null;
            });
        } catch (Exception e) {
            log.error("Failed to update predictor {}", predictorId, e);
        }
    }
}

From source file:org.apache.ctakes.ytex.uima.mapper.DocumentMapperServiceImpl.java

public Integer saveDocument(final JCas jcas, final String analysisBatch, final boolean bStoreDocText,
        final boolean bStoreCAS, final boolean bInsertAnnotationContainmentLinks,
        final Set<String> setTypesToIgnore) {
    if (log.isTraceEnabled())
        log.trace("begin saveDocument");
    // communicate options to mappers using thread local variable
    final DefaultTransactionDefinition txDef = new DefaultTransactionDefinition(
            TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    txDef.setIsolationLevel("orcl".equals(this.dbType) ? TransactionDefinition.ISOLATION_READ_COMMITTED
            : TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
    final TransactionTemplate txTemplate = new TransactionTemplate(this.getTransactionManager(), txDef);
    final int documentId = txTemplate.execute(new TransactionCallback<Integer>() {

        @Override//from  ww w.  ja  v a  2s  .co  m
        public Integer doInTransaction(TransactionStatus arg0) {
            Document doc = createDocument(jcas, analysisBatch, bStoreDocText, bStoreCAS);
            sessionFactory.getCurrentSession().save(doc);
            // make sure the document has been saved
            getSessionFactory().getCurrentSession().flush();
            saveAnnotationsHib(jcas, bInsertAnnotationContainmentLinks, setTypesToIgnore, doc);
            extractAndSaveDocKey(jcas, doc);
            return doc.getDocumentID();
        }
    });
    if (log.isTraceEnabled())
        log.trace("end saveDocument");
    return documentId;
}