spring jdbctemplate 事务不提交

nnnnn 发布于 2014/07/23 11:15
阅读 8K+
收藏 0

代码配置如下,本地环境:mysql5.6.19  spring4.02,研究几天没撤,有没有遇到这种问题的


CREATE TABLE `fitness` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) DEFAULT '' COMMENT '商品名称',
  `brand` varchar(50) DEFAULT '' COMMENT '品牌',
  `code` varchar(60) DEFAULT '' COMMENT '编码',
  `recommend` varchar(100) DEFAULT '' COMMENT '推荐',
  `price` double DEFAULT '0' COMMENT '价格',
  `function` varchar(255) DEFAULT '' COMMENT '功能',
  `weight` varchar(255) DEFAULT '' COMMENT '重量',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=1158036443 DEFAULT CHARSET=utf8 COMMENT='户外健身';


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

<!--  <context:property-placeholder properties-ref="deployProperties" />-->
<context:property-placeholder location="classpath:conf/jdbc.properties"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<!-- <property name="initialSize" value="${jdbc.initalize}"></property>
<property name="maxActive" value="${jdbc.maxActive}"></property>
<property name="maxIdle" value="${jdbc.maxIdle}"></property> -->
</bean>


<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
<property name="dataSource" ref="dataSource"/>
</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

<!--  <tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />     
        </property>
        <property name="transactionAttributes">
        <props>     
           <prop key="delete*">PROPAGATION_REQUIRED</prop>  
           <prop key="operate*">PROPAGATION_REQUIRED,-Exception</prop>     
           <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>     
           <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>     
           <prop key="save*">PROPAGATION_REQUIRED</prop>     
           <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>     
      </props>     
    </property>     
</bean>

<bean id="txProxy"    
         class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">     
        <property name="beanNames">     
          <list>     
             <value>*Service*</value>
          </list>     
        </property>     
        <property name="interceptorNames">     
          <list>     
             <value>transactionInterceptor</value>     
          </list>     
        </property>     
    </bean>   -->

<!-- 
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>

<aop:config proxy-target-class="true">
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.qtbobo.service.*.*(..))"/>
</aop:config> -->

<!--  <tx:jta-transaction-manager></tx:jta-transaction-manager>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="payService" class="com.qtbobo.service.PayService">
<property name="dataSource" ref="dataSource"/>
</bean>-->
<tx:annotation-driven transaction-manager="transactionManager"/>

<tx:advice id="txAdvice" transaction-manager="transactionManager"> 
    <tx:attributes> 
    <tx:method name="save*" propagation="REQUIRED" /> 
    <tx:method name="update*" propagation="REQUIRED" /> 
    <tx:method name="delete*" propagation="REQUIRED" />
    <tx:method name="query*" propagation="NOT_SUPPORTED" read-only="true" /> 
  </tx:attributes> 
    </tx:advice> 
    
    <aop:config> 
  <aop:pointcut id="allManagerMethod" 
  expression="execution(public * com.xue.service..*.*(..))" /> 
  <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice" /> 
  </aop:config>
</beans>






//加载Spring Context
public class DaoSupport {

private static ApplicationContext ctx;
private static PlatformTransactionManager txManager;
private static DataSource dataSource;
private static JdbcTemplate jdbcTemplate;

public ApplicationContext getCtx(){
String[] config = new String[]{
"classpath:conf/applicationContext.xml",
// "WEB-INF/conf/applicationContext.xml"
};
return new ClassPathXmlApplicationContext(config);
// return FileSystemXmlApplicationContext(config);
}

public DataSource getDataSource(){
return getCtx().getBean(DataSource.class);
}

public DataSourceTransactionManager geTransaction(){
return getCtx().getBean(DataSourceTransactionManager.class);
}

public JdbcTemplate getJdbcTemplate(){
return getCtx().getBean(JdbcTemplate.class);
}
}




public interface FitnessInterface {


   public void save(Fitness  fit);
   public void update(Fitness fit);
   public Fitness queryFitnessById(Integer id);
   public List<Fitness> queryAll();
   public void deleteFitness(long id);

}




public class FitnessServices extends DaoSupport implements FitnessInterface {

	private JdbcTemplate jdbcTemplate = getJdbcTemplate();
	
//	public FitnessServices(){
//		jdbcTemplate = new JdbcTemplate(getDataSource());
//	}
//	
	

	public void save(Fitness fit) {
		jdbcTemplate.update("insert into fitness values(?,?,?,?,?,?,?,?)",
				new Object[]{
					fit.getId(),fit.getName(),fit.getBrand(),fit.getCode(),fit.getRecommend(),
					fit.getPrice(),fit.getFunction(),fit.getWeight()});
	}

	public void update(Fitness fit) {
		jdbcTemplate.update("UPDATE fitness SET function=? WHERE id=?",
				new Object[]{fit.getFunction(),fit.getId()});
	}

	public Fitness queryFitnessById(Integer id) {
		return null;
	}

	public List<Fitness> queryAll() {
		
		return jdbcTemplate.query("select * from fitness", new BeanPropertyRowMapper<Fitness>(Fitness.class));
		 
	}


	public void deleteFitness(long id) {
		jdbcTemplate.update("delete from fitness where id=?",new Object[]{id},new int[]{java.sql.Types.INTEGER});
	}

}



exception:

11:11:45,635 main support.ClassPathXmlApplicationContext:513 - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@2984747e: startup date [Wed Jul 23 11:11:45 CST 2014]; root of context hierarchy
11:11:45,692 main xml.XmlBeanDefinitionReader:316 - Loading XML bean definitions from class path resource [conf/applicationContext.xml]
11:11:45,963 main support.PropertySourcesPlaceholderConfigurer:172 - Loading properties file from class path resource [conf/jdbc.properties]
11:11:46,381 main interceptor.NameMatchTransactionAttributeSource:96 - Adding transactional method [save*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
11:11:46,381 main interceptor.NameMatchTransactionAttributeSource:96 - Adding transactional method [update*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
11:11:46,381 main interceptor.NameMatchTransactionAttributeSource:96 - Adding transactional method [delete*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
11:11:46,381 main interceptor.NameMatchTransactionAttributeSource:96 - Adding transactional method [query*] with attribute [PROPAGATION_NOT_SUPPORTED,ISOLATION_DEFAULT,readOnly]
11:11:46,390 main core.JdbcTemplate:906 - Executing prepared SQL update
11:11:46,391 main core.JdbcTemplate:625 - Executing prepared SQL statement [UPDATE fitness SET function=? WHERE id=?]
11:11:46,395 main datasource.DataSourceUtils:110 - Fetching JDBC Connection from DataSource
11:11:46,708 main core.JdbcTemplate:916 - SQL update affected 1 rows
11:11:46,712 main datasource.DataSourceUtils:327 - Returning JDBC Connection to DataSource
11:11:46,812 main core.JdbcTemplate:906 - Executing prepared SQL update
11:11:46,813 main core.JdbcTemplate:625 - Executing prepared SQL statement [insert into fitness values(?,?,?,?,?,?,?,?)]
11:11:46,813 main datasource.DataSourceUtils:110 - Fetching JDBC Connection from DataSource
11:11:46,816 main datasource.DataSourceUtils:327 - Returning JDBC Connection to DataSource
11:11:46,824 main xml.XmlBeanDefinitionReader:316 - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
11:11:46,872 main support.SQLErrorCodesFactory:126 - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
11:11:46,872 main support.SQLErrorCodesFactory:199 - Looking up default SQLErrorCodes for DataSource [org.apache.commons.dbcp.BasicDataSource@65c9a477]
11:11:46,872 main datasource.DataSourceUtils:110 - Fetching JDBC Connection from DataSource
11:11:46,874 main datasource.DataSourceUtils:327 - Returning JDBC Connection to DataSource
11:11:46,874 main support.SQLErrorCodesFactory:217 - Database product name cached for DataSource [org.apache.commons.dbcp.BasicDataSource@65c9a477]: name is 'MySQL'
11:11:46,875 main support.SQLErrorCodesFactory:175 - SQL error codes for 'MySQL' found
11:11:46,875 main support.SQLErrorCodeSQLExceptionTranslator:397 - Translating SQLException with SQL state '23000', error code '1062', message [Duplicate entry '11134011' for key 'PRIMARY']; SQL was [insert into fitness values(?,?,?,?,?,?,?,?)] for task [PreparedStatementCallback]
Exception in thread "main" org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [insert into fitness values(?,?,?,?,?,?,?,?)]; Duplicate entry '11134011' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '11134011' for key 'PRIMARY'
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:907)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:968)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:978)
at com.xueyue.services.FitnessServices.save(FitnessServices.java:26)
at com.xueyue.snippet.FitnessTest.main(FitnessTest.java:30)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '11134011' for key 'PRIMARY'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2825)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2459)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2376)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2360)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:914)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:907)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:642)
... 5 more





加载中
0
nnnnn
nnnnn
怎么没人遇到嘛?
0
dreamers
dreamers
兄弟,能学下如何提问么?代码排版都没有,你叫人家如何看?要人copy一下,然后排版,再帮你解决?
0
nnnnn
nnnnn

引用来自“dreamers”的评论

兄弟,能学下如何提问么?代码排版都没有,你叫人家如何看?要人copy一下,然后排版,再帮你解决?
不好意思有点不太会用,刚改了一些排版
0
逝水fox
逝水fox
... 自己看异常输出 说的很明确 主键重复
0
nnnnn
nnnnn

引用来自“逝水fox”的评论

... 自己看异常输出 说的很明确 主键重复
难道事务中主键 重复就不能回滚之前的删除,更新,插入的数据嘛?
0
nnnnn
nnnnn
那条主键重复是我故意插入的,是想造成回滚之前更新的数据
0
nnnnn
nnnnn
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
	http://www.springframework.org/schema/aop 
	http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
	http://www.springframework.org/schema/context 
	http://www.springframework.org/schema/context/spring-context-3.2.xsd
	http://www.springframework.org/schema/tx 
	http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
	
	<context:component-scan base-package="com.xueyue" >   
    	<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />    
	</context:component-scan>
	
	<!--  <context:property-placeholder properties-ref="deployProperties" />-->
	<context:property-placeholder location="classpath:conf/jdbc.properties"/>
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
		<property name="driverClass" value="${jdbc.driver}"></property>
		<property name="jdbcUrl" value="${jdbc.url}"></property>
		<property name="user" value="${jdbc.username}"></property>
		<property name="password" value="${jdbc.password}"></property>
		<property name="acquireIncrement" value="${jdbc.acquireIncrement}"></property>
		<!-- <property name="initialSize" value="${jdbc.initalize}"></property>
		<property name="maxActive" value="${jdbc.maxActive}"></property>
		<property name="maxIdle" value="${jdbc.maxIdle}"></property> -->
	</bean>
	
	<!-- 
	
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="${jdbc.driver}"></property>
		<property name="url" value="${jdbc.url}"></property>
		<property name="username" value="${jdbc.username}"></property>
		<property name="password" value="${jdbc.password}"></property>
		<property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"></property>
		<property name="maxActive" value="${jdbc.maxActive}"></property>
		<property name="maxIdle" value="${jdbc.maxIdle}"></property>
	</bean>
	 -->
	
	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
		<constructor-arg ref="dataSource" />
	</bean>
	
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"/>
	</bean>
	<tx:annotation-driven transaction-manager="transactionManager"/>
	
	<!-- 
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="save*" propagation="REQUIRED" />
		</tx:attributes>
	</tx:advice>
	
	<aop:config proxy-target-class="true">
		<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.qtbobo.service.*.*(..))"/>
	</aop:config> -->
	
	<!--  <tx:jta-transaction-manager></tx:jta-transaction-manager>
	<tx:annotation-driven transaction-manager="transactionManager"/>
	<bean id="payService" class="com.qtbobo.service.PayService">
		<property name="dataSource" ref="dataSource"/>
	</bean>
	<tx:annotation-driven transaction-manager="transactionManager"/>
	
	<tx:advice id="txAdvice" transaction-manager="transactionManager"> 
   		<tx:attributes> 
   			<tx:method name="save*" propagation="REQUIRED" /> 
   			<tx:method name="update*" propagation="REQUIRED" /> 
   			<tx:method name="delete*" propagation="REQUIRED" />
   			<tx:method name="query*" propagation="NOT_SUPPORTED" read-only="true" /> 
  		</tx:attributes> 
   	</tx:advice> 
    
    <aop:config> 
  		<aop:pointcut id="allManagerMethod" 
  			expression="execution(public * com.xueyue.service..*.*(..))" /> 
  		<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice" /> 
 	</aop:config>-->
</beans>

事务总是不起作用



0
char1st
char1st
之前的那些 删除,更新,插入操作,事物已经提交了。 如果想要回滚请把那些操作写到一个事物里面。
0
nnnnn
nnnnn
信息: Initializing log4j from [D:\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\xueyue\WEB-INF\conf\log4j.properties]
七月 23, 2014 2:14:00 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'spring'
14:14:00,529 ContainerBackgroundProcessor[StandardEngine[Catalina]] servlet.DispatcherServlet:479 - FrameworkServlet 'spring': initialization started
14:14:00,531 ContainerBackgroundProcessor[StandardEngine[Catalina]] support.XmlWebApplicationContext:513 - Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Wed Jul 23 14:14:00 CST 2014]; parent: Root WebApplicationContext
14:14:00,532 ContainerBackgroundProcessor[StandardEngine[Catalina]] xml.XmlBeanDefinitionReader:316 - Loading XML bean definitions from ServletContext resource [/WEB-INF/conf/spring-servlet.xml]
14:14:00,616 ContainerBackgroundProcessor[StandardEngine[Catalina]] annotation.AutowiredAnnotationBeanPostProcessor:141 - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
14:14:00,662 ContainerBackgroundProcessor[StandardEngine[Catalina]] annotation.RequestMappingHandlerMapping:182 - Mapped "{[/index],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.xueyue.contor.IndexXueyueController.submit()
14:14:00,864 ContainerBackgroundProcessor[StandardEngine[Catalina]] handler.SimpleUrlHandlerMapping:315 - Mapped URL path [/**] onto handler 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0'
14:14:00,875 ContainerBackgroundProcessor[StandardEngine[Catalina]] handler.SimpleUrlHandlerMapping:315 - Mapped URL path [/images/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
14:14:00,876 ContainerBackgroundProcessor[StandardEngine[Catalina]] handler.SimpleUrlHandlerMapping:315 - Mapped URL path [/style/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1'
14:14:00,877 ContainerBackgroundProcessor[StandardEngine[Catalina]] handler.SimpleUrlHandlerMapping:315 - Mapped URL path [/vscripts/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#2'
14:14:00,889 ContainerBackgroundProcessor[StandardEngine[Catalina]] servlet.DispatcherServlet:498 - FrameworkServlet 'spring': initialization completed in 360 ms
七月 23, 2014 2:14:00 下午 org.apache.catalina.core.StandardContext reload
信息: Reloading Context with name [/xueyue] is completed
14:14:01,657 http-bio-8080-exec-1 support.ClassPathXmlApplicationContext:513 - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@4c3f1f6f: startup date [Wed Jul 23 14:14:01 CST 2014]; root of context hierarchy
14:14:01,658 http-bio-8080-exec-1 xml.XmlBeanDefinitionReader:316 - Loading XML bean definitions from class path resource [conf/applicationContext.xml]
14:14:01,687 http-bio-8080-exec-1 support.PropertySourcesPlaceholderConfigurer:172 - Loading properties file from class path resource [conf/jdbc.properties]
14:14:01,688 http-bio-8080-exec-1 annotation.AutowiredAnnotationBeanPostProcessor:141 - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
14:14:01,724 http-bio-8080-exec-1 core.JdbcTemplate:906 - Executing prepared SQL update
14:14:01,725 http-bio-8080-exec-1 core.JdbcTemplate:625 - Executing prepared SQL statement [UPDATE fitness SET function=? WHERE id=?]
14:14:01,729 http-bio-8080-exec-1 datasource.DataSourceUtils:110 - Fetching JDBC Connection from DataSource
14:14:01,755 http-bio-8080-exec-1 impl.AbstractPoolBackedDataSource:522 - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1hge15y93r5g2k7l0t8zs|58608f93, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceUseNamedDriverClass -> false, identityToken -> 1hge15y93r5g2k7l0t8zs|58608f93, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://127.0.0.1:3306/mall?useUnicode=true&amp;characterEncoding=utf-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
14:14:02,006 http-bio-8080-exec-1 core.JdbcTemplate:916 - SQL update affected 1 rows
14:14:02,009 http-bio-8080-exec-1 datasource.DataSourceUtils:327 - Returning JDBC Connection to DataSource

还是不能回滚



0
nnnnn
nnnnn

引用来自“char1st”的评论

之前的那些 删除,更新,插入操作,事物已经提交了。 如果想要回滚请把那些操作写到一个事物里面。
你的意思是插入和更新是两个事务,各走各的了
返回顶部
顶部