spring代理iBATIS时事务不能回滚
kkkk如题!
废话不多说了,直接上配置,配置如下,各位看了便知!
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><bean destroy-method="close"><property name="url"><value>${jdbc.url}</value></property><property name="driverClassName"><value>${jdbc.driver}</value></property><property name="username"><value>${jdbc.username}</value></property><property name="password"><value>${jdbc.password}</value></property><property name="defaultAutoCommit" value="false"></property></bean><bean id="transactionManager" ref="dataSource"/></bean><bean id="transactionInterceptor" ><property name="transactionManager" ref="transactionManager" /><property name="transactionAttributes"><props><prop key="find*">PROPAGATION_REQUIRED,readOnly</prop><prop key="*">PROPAGATION_REQUIRED,-Exception</prop></props></property></bean><bean ref="dataSource"></property><property name="lobHandler"><bean ref="sqlMapClientFactory" /><property name="exceptionTranslator"><bean ref="dataSource" /></bean></property></bean></beans>
?daoContext.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><bean id="employeeDao" /></property></bean></beans>
?serviceContext.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><bean id="employeeService" /></property></bean></beans>
在EmployeeServiceImpl中故意让程序抛出了exception,但是事务仍然提交了:-(
}