日期:2014-05-19  浏览次数:20775 次

事务的处理问题
框架用的ibatis和springMVC

spring配置如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
 "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--  连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">

<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/wms_db" /> 
<property name="user" value="root" />
<property name="password" value="root" />
   <property name="initialPoolSize" value="20" />
<property name="minPoolSize" value="20" />
<property name="maxPoolSize" value="20" />
    <property name="acquireIncrement" value="5" />
<property name="maxIdleTime" value="10" />
<property name="maxStatements" value="0" />
<property name="testConnectionOnCheckin" value="true" />
<property name="testConnectionOnCheckout" value="true" />
<property name="idleConnectionTestPeriod" value="30" />
</bean>

<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager ">
<property name="dataSource" ref="dataSource" />

</bean>
 
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="/WEB-INF/ibatis/sqlMapConfig.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
 <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
 
           <property name="transactionManager">

               <ref local="transactionManager" />
           </property>
 
           <property name="transactionAttributes">
               <props>
                  <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
               </props>
           </property>
        </bean>

<bean name="beanNameAutoProxy"

class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator" />

<bean id="transactionProxy" parent="beanNameAutoProxy">

<property name="beanNames">
<list>
<value>*Impl</value>
</list>
</property>

<property name="interceptorNames">
<value>transactionInterceptor</value>
</property>

</bean>

</beans>


现在我需要执行一批insert 和一批upda