Environment:
apache tomcat 7
java 7
oracle 11g
eclipse
apache jmeter 2.1
Extending Azizi's answer...
@Transactional makes Spring wrap the class in AOP proxy. The target method execution is then wrapped in transaction interceptor. So the overall call looks like this:
-> FooProxy#generateSequenseNumber
-> TransactionInterceptor#invoke
-> BEGIN TRANSACTION
-> Foo#generateSequenceNumber (synchronized)
-> COMMIT|ROLLBACK TRANSACTION
You can (and should) try to put breakpoint inside your method to see what is on the stack.
If you want to solve the synchronization inside your generateSequenseNumber method, then you can use TransactionTemplate and REQUIRES_NEW propagation. Of course then the @Transactional annotation would make no sense.