Java Code Examples for org.springframework.transaction.interceptor.DefaultTransactionAttribute#setPropagationBehavior()
The following examples show how to use
org.springframework.transaction.interceptor.DefaultTransactionAttribute#setPropagationBehavior() .
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: TransactionAdviceConfig.java From SpringBoot2.0 with Apache License 2.0 | 6 votes |
@Bean public TransactionInterceptor txAdvice() { DefaultTransactionAttribute required = new DefaultTransactionAttribute(); required.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); DefaultTransactionAttribute readonly = new DefaultTransactionAttribute(); readonly.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); readonly.setReadOnly(true); NameMatchTransactionAttributeSource source = new NameMatchTransactionAttributeSource(); source.addTransactionalMethod("add*", required); source.addTransactionalMethod("save*", required); source.addTransactionalMethod("delete*", required); source.addTransactionalMethod("update*", required); source.addTransactionalMethod("exec*", required); source.addTransactionalMethod("set*", required); source.addTransactionalMethod("do*", required); source.addTransactionalMethod("get*", readonly); source.addTransactionalMethod("query*", readonly); source.addTransactionalMethod("find*", readonly); source.addTransactionalMethod("list*", readonly); source.addTransactionalMethod("count*", readonly); return new TransactionInterceptor(transactionManager, source); }
Example 2
Source File: TransactionJobDemo.java From SpringAll with MIT License | 5 votes |
private Step step() { DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); attribute.setPropagationBehavior(Propagation.REQUIRED.value()); attribute.setIsolationLevel(Isolation.DEFAULT.value()); attribute.setTimeout(30); return stepBuilderFactory.get("step") .<String, String>chunk(2) .reader(listItemReader()) .writer(list -> list.forEach(System.out::println)) .readerIsTransactionalQueue() .transactionAttribute(attribute) .build(); }