I have a method that has two annotations:
@Transactional
@SchedulerLock
public void test() {
// do something
}
I'm wondering what happens first. Will first be a transaction created and then the locking will happen, or the other way round? Or isn't this even determined?
I tried to figure this out by reading the documentation, but I'm unsure where to even start. The only thing I could find was a random comment without source that said that the order is random.
In general the relative order of annotation aspect is not specified be default, moreover it might vary from version to version.
As it is mentioned in the answer to this question you can specify the order:
The link there points to outdated documentation, so if you really need ordering I'd split this method into two, moving each into separate component and call one from another one (or vice versa), e.g.: