Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Autowired
- private PlatformTransactionManager transactionManager;
- public void doSomething() {
- DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
- definition.set...
- // begin transaction
- TransactionStatus transaction = transactionManager.getTransaction(definition);
- try {
- // do something
- transactionManager.commit(transaction);
- } catch (Exception e) {
- // here transaction should be still active
- transactionManager.rollback(transaction);
- // here transaction should be rolled back
- throw e;
- }
- }
Add Comment
Please, Sign In to add comment