List of usage examples for org.springframework.transaction.interceptor DefaultTransactionAttribute setIsolationLevel
public final void setIsolationLevel(int isolationLevel)
From source file:org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.java
@SuppressWarnings("serial") private void configureTaskletStep(TaskletStep ts) { configureAbstractStep(ts);//from w w w .j av a 2 s . c o m if (listeners != null) { List<ChunkListener> newListeners = new ArrayList<ChunkListener>(); for (StepListener listener : listeners) { if (listener instanceof ChunkListener) { newListeners.add((ChunkListener) listener); } } ts.setChunkListeners(newListeners.toArray(new ChunkListener[0])); } if (tasklet != null) { ts.setTasklet(tasklet); } if (taskExecutor != null) { TaskExecutorRepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate(); repeatTemplate.setTaskExecutor(taskExecutor); if (throttleLimit != null) { repeatTemplate.setThrottleLimit(throttleLimit); } ts.setStepOperations(repeatTemplate); } if (transactionManager != null) { ts.setTransactionManager(transactionManager); } if (transactionTimeout != null || propagation != null || isolation != null || noRollbackExceptionClasses != null) { DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); if (propagation != null) { attribute.setPropagationBehavior(propagation.value()); } if (isolation != null) { attribute.setIsolationLevel(isolation.value()); } if (transactionTimeout != null) { attribute.setTimeout(transactionTimeout); } Collection<Class<? extends Throwable>> exceptions = noRollbackExceptionClasses == null ? new HashSet<Class<? extends Throwable>>() : noRollbackExceptionClasses; final BinaryExceptionClassifier classifier = new BinaryExceptionClassifier(exceptions, false); ts.setTransactionAttribute(new DefaultTransactionAttribute(attribute) { @Override public boolean rollbackOn(Throwable ex) { return classifier.classify(ex); } }); } }
From source file:org.springframework.batch.core.step.factory.SimpleStepFactoryBean.java
/** * Getter for the {@link TransactionAttribute} for subclasses only. * @return the transactionAttribute//from ww w.j a v a2 s . c o m */ @SuppressWarnings("serial") protected TransactionAttribute getTransactionAttribute() { DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); attribute.setPropagationBehavior(propagation.value()); attribute.setIsolationLevel(isolation.value()); attribute.setTimeout(transactionTimeout); return new DefaultTransactionAttribute(attribute) { /** * Ignore the default behaviour and rollback on all exceptions that bubble up to the tasklet level. The * tasklet has to deal with the rollback rules internally. */ @Override public boolean rollbackOn(Throwable ex) { return true; } }; }
From source file:org.springframework.batch.core.step.item.SimpleStepFactoryBean.java
/** * Getter for the {@link TransactionAttribute} for subclasses only. * @return the transactionAttribute//from www.j ava 2 s. c o m */ @SuppressWarnings("serial") protected TransactionAttribute getTransactionAttribute() { DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); attribute.setPropagationBehavior(propagation.value()); attribute.setIsolationLevel(isolation.value()); attribute.setTimeout(transactionTimeout); return new DefaultTransactionAttribute(attribute) { /** * Ignore the default behaviour and rollback on all exceptions that * bubble up to the tasklet level. The tasklet has to deal with the * rollback rules internally. */ @Override public boolean rollbackOn(Throwable ex) { return true; } }; }
From source file:uk.ac.ebi.phenotype.solr.indexer.AbstractIndexer.java
protected void initialiseHibernateSession(ApplicationContext applicationContext) { // allow hibernate session to stay open the whole execution PlatformTransactionManager transactionManager = (PlatformTransactionManager) applicationContext .getBean("transactionManager"); DefaultTransactionAttribute transactionAttribute = new DefaultTransactionAttribute( TransactionDefinition.PROPAGATION_REQUIRED); transactionAttribute.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE); transactionManager.getTransaction(transactionAttribute); }