2
回答
spring配置事务不回滚,晕了
终于搞明白,存储TCO原来是这样算的>>>   

回滚不成功,不明白为什么。配置

<!-- 定时计划任务配置 -->

	<context:annotation-config />
	<context:component-scan base-package="*" />
	<context:property-placeholder location="classpath:jdbc.properties" />
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${driverClassName}" />
		<property name="url" value="${url}" />
		<property name="username" value="${username}" />
		<property name="password" value="${password}" />
		<!-- 连接池启动时的初始值 -->
		<property name="initialSize" value="${initialSize}" />
		<!-- 连接池的最大值 -->
		<property name="maxActive" value="${maxActive}" />
		<!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 -->
		<property name="maxIdle" value="${maxIdle}" />
		<!--  最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 -->
		<property name="minIdle" value="${minIdle}" />
		<property name="maxWait"><value>60000</value></property>
		<property name="removeAbandoned"><value>true</value></property>  
		<property name="removeAbandonedTimeout"><value>180</value></property>  
		<property name="testWhileIdle"><value>true</value></property> <!-- 打开检查,用异步线程evict进行检查 -->  
		<property name="testOnBorrow"><value>false</value></property>  
		<property name="testOnReturn"><value>false</value></property>  
		<property name="validationQuery"><value>SELECT 1</value></property>  
		<property name="validationQueryTimeout"><value>1</value></property>  
		<property name="timeBetweenEvictionRunsMillis"><value>30000</value></property>  
		<property name="numTestsPerEvictionRun"><value>20</value></property>  

	</bean>
	<!---/**配置事务管理**/-->
	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>
	<tx:annotation-driven transaction-manager="transactionManager" />

DEBUG - Found injected element on class [test2.SpringTest]: AutowiredFieldElement for private com.toihk.service.PIManage test2.SpringTest.service

DEBUG - Processing injected method of bean 'test2.SpringTest': AutowiredFieldElement for private com.toihk.service.PIManage test2.SpringTest.service
DEBUG - Returning cached instance of singleton bean 'PIManageImpl'
DEBUG - Autowiring by type from bean name 'test2.SpringTest' to bean named 'PIManageImpl'
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
DEBUG - Adding transactional method 'testAddOpinion1' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG - Creating implicit proxy for bean 'test2.SpringTest' with 0 common interceptors and 1 specific interceptors
DEBUG - Creating CGLIB2 proxy: target source is SingletonTargetSource for target object [test2.SpringTest@b7efd4]
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.interceptor.TransactionInterceptor#0'
DEBUG - Unable to apply any optimisations to advised method: public void test2.SpringTest.testAddOpinion1()
DEBUG - Found 'hashCode' method: public native int java.lang.Object.hashCode()
DEBUG - Found 'equals' method: public boolean java.lang.Object.equals(java.lang.Object)
DEBUG - Unable to apply any optimisations to advised method: protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException
DEBUG - Unable to apply any optimisations to advised method: public java.lang.String java.lang.Object.toString()
DEBUG - Found finalize() method - using NO_OVERRIDE
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isFrozen()
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isProxyTargetClass()
DEBUG - Method is declared on Advised interface: public abstract java.lang.Class[] org.springframework.aop.framework.Advised.getProxiedInterfaces()
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isInterfaceProxied(java.lang.Class)
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setTargetSource(org.springframework.aop.TargetSource)
DEBUG - Method is declared on Advised interface: public abstract org.springframework.aop.TargetSource org.springframework.aop.framework.Advised.getTargetSource()
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setExposeProxy(boolean)
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isExposeProxy()
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setPreFiltered(boolean)
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isPreFiltered()
DEBUG - Method is declared on Advised interface: public abstract org.springframework.aop.Advisor[] org.springframework.aop.framework.Advised.getAdvisors()
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(int,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvisor(org.springframework.aop.Advisor)
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.removeAdvisor(int) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.springframework.aop.Advisor)
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.replaceAdvisor(org.springframework.aop.Advisor,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(int,org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvice(org.aopalliance.aop.Advice)
DEBUG - Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.aopalliance.aop.Advice)
DEBUG - Method is declared on Advised interface: public abstract java.lang.String org.springframework.aop.framework.Advised.toProxyConfigString()
DEBUG - Method is declared on Advised interface: public abstract java.lang.Class org.springframework.aop.TargetClassAware.getTargetClass()
DEBUG - Adding transactional method 'testAddOpinion1' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG - Explicit transaction definition [PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''] found for test context [[TestContext@ba90e3 testClass = SpringTest, locations = array<String>['classpath:/test2/flex-servlet.xml'], testInstance = test2.SpringTest@b7efd4, testMethod = testAddOpinion1@SpringTest, testException = [null]]]
DEBUG - Retrieved @TransactionConfiguration [@org.springframework.test.context.transaction.TransactionConfiguration(defaultRollback=true, transactionManager=transactionManager)] for test class [class test2.SpringTest]
DEBUG - Retrieved TransactionConfigurationAttributes [[TransactionConfigurationAttributes@b5cfaf transactionManagerName = 'transactionManager', defaultRollback = true]] for class [class test2.SpringTest]
DEBUG - Returning cached instance of singleton bean 'transactionManager'
DEBUG - Creating new transaction with name [testAddOpinion1]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG - Acquired Connection [jdbc:mysql://localhost:3306/toihk0919?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull, UserName=root @localhost , MySQL-AB JDBC Driver] for JDBC transaction
DEBUG - Switching JDBC Connection [jdbc:mysql://localhost:3306/toihk0919?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull, UserName=root @localhost , MySQL-AB JDBC Driver] to manual commit
DEBUG - No method-level @Rollback override: using default rollback [true] for test context [[TestContext@ba90e3 testClass = SpringTest, locations = array<String>['classpath:/test2/flex-servlet.xml'], testInstance = test2.SpringTest@b7efd4, testMethod = testAddOpinion1@SpringTest, testException = [null]]]
INFO - Began transaction (1): transaction manager [org.springframework.jdbc.datasource.DataSourceTransactionManager@ec2268]; rollback [true]
-----------------------------------------start
DEBUG - Executing prepared SQL query
DEBUG - Executing prepared SQL statement [SELECT count(1) num FROM product_po WHERE STATUS IN ('ACTIVE','PO','KIT','PART','KITED','PARTED','CANCLE','OPEN','CLOSE') AND piId=?]
DEBUG - Executing prepared SQL update
DEBUG - Executing prepared SQL statement [update pi set status='CANCLE' where id=?]
DEBUG - SQL update affected 1 rows
DEBUG - Executing prepared SQL query
DEBUG - Executing prepared SQL statement [select qty,productId from pi_item where piId=?]
DEBUG - No method-level @Rollback override: using default rollback [true] for test context [[TestContext@ba90e3 testClass = SpringTest, locations = array<String>['classpath:/test2/flex-servlet.xml'], testInstance = test2.SpringTest@b7efd4, testMethod = testAddOpinion1@SpringTest, testException = java.lang.IllegalArgumentException: SQL array must not be empty]]
DEBUG - Initiating transaction rollback
DEBUG - Rolling back JDBC transaction on Connection [jdbc:mysql://localhost:3306/toihk0919?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull, UserName=root@localhost , MySQL-AB JDBC Driver]
DEBUG - Releasing JDBC Connection [jdbc:mysql://localhost:3306/toihk0919?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull, UserName=root @localhost , MySQL-AB JDBC Driver] after transaction
DEBUG - Returning JDBC Connection to DataSource
INFO - Rolled back transaction after test execution for test context [[TestContext@ba90e3 testClass = SpringTest, locations = array<String>['classpath:/test2/flex-servlet.xml'], testInstance = test2.SpringTest@b7efd4, testMethod = testAddOpinion1@SpringTest, testException = java.lang.IllegalArgumentException: SQL array must not be empty]]
DEBUG - After test method: context [[TestContext@ba90e3 testClass = SpringTest, locations = array<String>['classpath:/test2/flex-servlet.xml'], testInstance = test2.SpringTest@b7efd4, testMethod = testAddOpinion1@SpringTest, testException = java.lang.IllegalArgumentException: SQL array must not be empty]], class dirties context [false], class mode [null], method dirties context [false].
DEBUG - After test class: context [[TestContext@ba90e3 testClass = SpringTest, locations = array<String>['classpath:/test2/flex-servlet.xml'], testInstance = [null], testMethod = [null], testException = [null]]], dirtiesContext [false].
INFO - Closing org.springframework.context.support.GenericApplicationContext@c1f3ae: startup date [Thu Sep 12 18:40:04 CST 2013]; root of context hierarchy
DEBUG - Returning cached instance of singleton bean 'lifecycleProcessor'
INFO - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@e757f7: defining beans [*]; root of factory hierarchy
DEBUG - Retrieved dependent beans for bean 'PIManageImpl': [test2.SpringTest]
DEBUG - Invoking destroy method 'close' on bean with name 'dataSource'

举报
fir01
发帖于4年前 2回/8K+阅
顶部