songeddy 2014-04-06 03:41
浏览 1931

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 {

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿