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 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器