I have a question about Spring 3.2.3 @Transactional annotation. My Service class looks like this:
@Service @Transactional
class InventoryDisclosureBO {
@Aut
This is related to how spring generates the transactional proxies.
In the case where you have @Transactional at the class level, when you call InventoryDisclosureBO.processDisclosureData()
, in fact, you're calling a Spring proxy that starts the transaction, and then calls the real implementation.
If you only have @Transaction in persis(), spring doesn't start a transaction when you call InventoryDisclosureBO.processDisclosureData()
, and then it cannot detect that you've called InventoryDisclosureBO.persist()
So Spring basically ignores the annotation on persist
, because it cannot add the transactional proxy.
As a rule of thumb, the @Transactional annotation should be on a public method, and hopefully quite high in the call hierarchy (otherwise each persist would end up creating a new transaction)
You might find more information on this other SO question: Method Interceptor on private methods (any non-public methods behave in the same way)