Transaction Management Using Spring
I am working on persisting associated objects in single transaction .
Got started with declaring following attributes in applicationContext.xml using TransactionProxy which in turn uses HibernateTransactionManager as shown below
Code:
<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="store*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
<property name="preInterceptors">
<list>
</list>
</property>
<property name="postInterceptors">
<list>
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
As i am newbie to using Transaction management not sure what should be my next steps. I am thinking of the following
- Declare the methods to be in transaction similar to EJB2.0 . But not seen an example of such kind on google search. Their are examples declaring bean to be in transaction like
Code:
<bean id="manufManager" parent="txProxyTemplate">
<property name="proxyInterfaces">
<value>com.example.service.ManufacturerManager</value>
</property>
<property name="target">
<bean class="com.boeing.nmt.nams.service.impl.ManufacturerManagerImpl">
<property name="manufDao" ref="manufDao"/>
<property name="namsUserDao" ref="namsUserDao"/>
</bean>
</property>
</bean>
So i am not sure how to declare calling and called methods in Transaction as similar to in EJB2.0
- I am not sure how to design one method calling the other in single Transaction in code .
Any pointers/suggestions will be highly appreciated
Regards
Bansi