Is Spring Retry guaranteed to work with Spring's @Transactional
annotation?
Specifically, I'm trying to use @Retryable
for optimistic locking. It seems like it would be dependent on the ordering of the AOP proxies that were created. For example, if the calls look like this:
Calling code -> Retry Proxy -> Transaction Proxy -> Actual DB Code
Then it would work correctly, but if the proxies were structured like this:
Calling code -> Transaction Proxy -> Retry Proxy -> Actual DB Code
Then the retry wouldn't work, because the act of closing the transaction is what throws the optmistic locking exception.
In testing, it appeared to generate the first case (retry, then transaction), but I couldn't tell if this was a guaranteed behavior or just lucky.