I have a Spring+Hibernate application with declarative transaction management.
I have a service (FooService
) which has 2 public methods MethodA
and MethodB
. The client will call
the MethodA
which in turn will call the MethodB
.
Client -> MethodA -> MethodB
I want the transaction to start only from MethodB onwards. This is a snippet from my spring application-context:
<bean id="FooService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager" />
<property name="target" ref="FooServiceTarget" />
<property name="transactionAttributes">
<props>
<prop key="MethodB">PROPAGATION_REQUIRED,-FooException</prop>
</props>
</property>
</bean>
However, when I invoke the MethodA
from my client, it doesn't create a transaction proxy when MethodB
is to be called.
If I add MethodA
also to the bean configuration in application-context, the transaction proxy is invoked (starting MethodA
, as expected).
Why is this so? Can I achieve transaction being created only from MethodB onwards?