I solved the problem. It turns out I'm not particularly familiar with spring's business as a principle.
The solution is as follows:
Principle: Spring AOP Exception Trapping principle: The method being intercepted explicitly throws an exception, and cannot be processed, so that the AOP agent can catch the exception of the method in order to rollback, by default, AOP catches only runtimeexception exceptions, but can be
<tx:method name= "upd*" propagation= "REQUIRED" rollback-for= "Java.lang.Exception"/>
Configuration to catch a specific exception and roll back
In other words, no try catch is used in the service's method or a throw new Runtimeexcetpion () is finally added to the catch, so that the program can be caught by AOP and then rolled back.
Solution:
Scenario 1. For example, the service layer processes the transaction, then no exception is caught in the methods in the service, or the throw new RuntimeException () statement is finally added to the catch statement so that AOP catches the exception and then rolls back. And on the service upper level (WebService client, view layer action) to continue catching this exception and handling
Scenario 2. Add: Transactionaspectsupport.currenttransactionstatus (). Setrollbackonly () in the catch statement of the service layer method; statement, manual rollback, So that the upper layer does not have to deal with the exception (now the project practice)
<bean id= "TransactionManager"
class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name= "Sessionfactory" ref= "Sessionfactory"/>
</bean>
<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >
<tx:attributes>
<tx:method name= "add*" propagation= "REQUIRED"/>
<tx:method name= "upd*" propagation= "REQUIRED" rollback-for= "Java.lang.Exception"/>
<tx:method name= "del*" propagation= "REQUIRED"/>
<tx:method name= "*" propagation= "SUPPORTS"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id= "Canyin" expression= "Execution (* com.laphone.base.baseservice.*.* (..)) | | Execution (* com.laphone.canyin.*.service.*.* (..)) | | Execution (* com.laphone.canyin.*.*.service.*.* (..)) " />
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "Canyin"/>
</aop:config>
The transaction is configured in spring, the data business layer catches the exception, and the transaction configuration is unsuccessful?