I tried using the following, pretty standard, configuration to open my hibernate session and declaratively demarcate transactions:
Attempting to use this code resulted in HibernateTransactionManager not opening a Session unless the method name in my service object matched "save*" or "del*".
<bean id="txProxyTemplate" abstract="true" singleton="true"
<!---- NOTICE THE FOLLOWING LINE ---->
<bean id="aService" parent="txProxyTemplate">
Now, I understand than the hibernate transaction manager opens a session and creates a transaction according to the transactionAttributes but it took be quite a while to make the inverse realization that since PROPAGATION_SUPPORTS implies that a transaction will not be started (unless that is there is a surrounding tx which is not my case) the hibernate session won't be opened either.
So, what is one supposed to do:
- 1. avoid PROPAGATION_SUPPORTS?
2. use a HibernateInterceptor as well (using the postInterceptors attribute of the TransactionProxyFactoryBean)?
My opinion is that the session should be opened by the TransactionProxyFactoryBean even when using PROPAGATION_SUPPORTS.
In any case I think this point could be made somewhere in the documentation, ie, that the session won't be opened unless a transaction is started, even if the method name is matched against the transactionAttributes.