Transaction Management and spring transaction management
1. Add cglib. jar
2. Add the following configuration to spring. xml:
<! -- Transaction Manager -->
<Bean id = "txManager"
Class = "org. springframework. orm. hibernate4.HibernateTransactionManager">
<! -- <Property name = "dataSource" ref = "myDataSource"> </property> -->
<Property name = "sessionFactory" ref = "sessionFactory"/>
</Bean>
<Aop: config proxy-target-class = "true">
<Aop: pointcut expression = "execution (* com. arhat. service. impl .*.*(..))"
Id = "txCut"/>
<Aop: advisor advice-ref = "txAdvice" pointcut-ref = "txCut"/>
</Aop: config>
<Tx: advice id = "txAdvice" transaction-manager = "txManager">
<! -- Propagation attribute of a transaction -->
<Tx: attributes>
<Tx: method name = "*" propagation = "SUPPORTS" read-only = "true"/>
<Tx: method name = "save *" propagation = "REQUIRED"> </tx: method>
<Tx: method name = "update *" propagation = "REQUIRED"> </tx: method>
<Tx: method name = "delete *" propagation = "REQUIRED"> </tx: method>
</Tx: attributes>
</Tx: advice>