It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

TransactionTemplate or @Transactional?

Should I be using TransactionTemplate directly, or using @Transactional, when accessing ActiveObjects in an add-on?

The ActiveObjects doco mentions @Transactional, but the Stash SSH plugin uses TransactionTemplate, and I can't remember why.

1 answer

1 accepted

0 votes
Answer accepted

Hi David,

From a plugin you should be using TransactionTemplate (imported from SAL). It will do all the necessary plumbing to ensure your DB operations are performed transactionally.

As you mentioned the SshKeyServiceImpl from the SSH plugin is a good example of how to use it.



I suspected that was the case. So the approach described by the ActiveObjects doco is not right? It suggests using:


Actually digging into it a bit further looks like @Transactional would work too, though with slightly more overhead. Services marked with @Transactional will end up being wrapped in a dynamic proxy that uses TransactionTemplate (provided you have the right bean post-processors wired into your plugin), so either method is probably ok.

To be honest, I'd still be going with TransactionTemplate for the sake of simplicity and not tying yourself further to the AO library.

You make a good point about independence from the AO library. Thanks mate.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted yesterday in United States

Atlassian Government Symposium

Good day members, Not sure if you are aware that Atlassian will be hosting a Government Symposium on May 1st, 2019 in Washington DC. For more details please click here If you have any questions...

15 views 0 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you