SSH transaction configuration

<!-- Configure Hibernate's local transaction manager, use the HibernateTransactionManager class -->
<!-- This class implements the PlatformTransactionManager interface, which is a specific implementation for Hibernate -->
<bean id="transactionManager"
class="org.springframework .orm.hibernate3.HibernateTransactionManager">
<!-- When configuring HibernateTransactionManager, you need to inject the reference of SessionFactory -->
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- Configure transaction aspect Bean , specify the transaction manager -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- Used to configure detailed transaction semantics -->
<tx:attributes>
<tx:method name= "insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />

</tx:attributes>
</tx:advice>
<aop:config>
<!--
Configure a pointcut that matches the execution of all methods of all classes ending with Impl under the com.demo.hibernate.service package
-->
<aop:pointcut id="leePointcut"
expression="execution(* com.demo.hibernate.service.*Impl.*(..))" />
<!-- Specifies to apply the txAdvice transaction aspect at the txAdvice pointcut-- >
<aop:advisor advice-ref="txAdvice" pointcut-ref="leePointcut" />
</aop:config>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327070754&siteId=291194637