2 songeddy songeddy 于 2014.04.06 11:41 提问

spring注解方式事务控制没有回滚

项目中使用到了hibernate以及spring事务控制,在service层增加事务控制但是遇到异常没有回滚。
代码如下:
配置文件
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-autowire="byName" default-lazy-init="true">
















<!-- 字典信息 -->
com.cvicse.tech.dic.model.DCoreParam
com.cvicse.tech.dic.model.DDicContent
com.cvicse.tech.dic.model.DDicType
com.cvicse.tech.dic.model.DZoneCode
com.cvicse.tech.dic.model.DDepMode




<!-- see /components/orm/hibernate/meta/dialect.properties for all Dialect -->
${hibernate.dialect}
${hibernate.show_sql}
${hibernate.cache.provider_class}
${hibernate.cache.use_query_cache}




id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >



service层代码
@Transactional
public class LrbManager {

private LrbDAOImpl lrbDao;
private Sql sql;

@Transactional
public void delete() throws ApplicationException {
sql.setSql("insert into sjcj_lrb (SXH, XM, HC, SNTQLJ, BYS, BNLJS, JBJG, JBR, JBSJ, DWMC, SSRQ) values('5','1','1','121','1','1','1','1','2014-03-30','1','2014-03-30')");
sql.executeUpdate();
sql.setSql("insert into sjcj_lrb (SXH, XM, HC, SNTQLJ, BYS, BNLJS, JBJG, JBR, JBSJ, DWMC, SSRQ) values('6','1','1','121','1','1','1','1','2014-03-30','1','2014-03-30')");
sql.executeUpdate();

//抛异常语句
sql.setSql("delte from sjcj_lrb1 ");
sql.executeUpdate();
}
}

/**
*关于SQL语句的一些操作
*/
public class Sql extends JdbcDaoSupport {

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!