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.
Community moderators have prevented the ability to post new answers.
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.
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.
What’s New as of May 21, 2020 Hi there! We recently made some changes to the way you can leverage Single-sign on and authorization within Opsgenie. Based on customer preference and feedback we intr...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events