AlgoTraderAlgoTrader Documentation

Chapter 6. Database

6.1. Database scripts
6.2. Transaction Handling

Using Spring Transaction Boundaries are declared on Services using the annotation @Transactional. Transaction Boundaries are handled by the org.springframework.transaction.interceptor.TransactionInterceptor. A typical declaration looks like this:

@Transactional(propagation = Propagation.SUPPORTS)

public class TransactionServiceImpl implements TransactionService {
    @Transactional(propagation = Propagation.REQUIRED)
    public void saveTransaction(final Transaction transaction) {
        ...
    }
...
}

In order for transactions to work services need to implement an interface (e.g. TransactionServiceImpl implements TransactionService).