我用的是struts1+hiebrnate+Spring在Struts_config.xml中 定义action类scope="request"是指每一个请求都生成一个action对象,
现在我的每个action都继承了一个 baseaction  类 
而且在这个父类中还有调用了很多业务类(services)方法(常常从request中取数据),事物控制也是在业务层,老是出现莫名其妙的事物错误
Could not synchronize database state with sessionorg.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.introns.model.goods.NetGoods#402880d31fa720c1011fa72605690001]我在想是不是因为baseaction类没有自动生成一个类 而是都重用了 造成很多对象用一个baseaction类(而它有用了很多从request中取得数据) 导致错误啊?

解决方案 »

  1.   

    很多业务类(services)方法Row was updated or deleted by another transaction 
    baseaction  封装了 hibernate数据库操作?肯定不行!!!
      

  2.   

    为什么啊 现在都写成这样了 要改很困难了  比如 在baseaction中的 execute前后加了很多操作,
      

  3.   

    我这么想的
    action创建多个 那么baseaction 就会有多个所有可能会有多个线程去操作 baseaction 类中的hibernate session这个异常
    Row was updated or deleted by another transaction 我怀疑就是多线程操作过程中出现的问题
      

  4.   

    // 0 表示进入表单   只有get   get和submit时放数据到request 用来业务表使用
    workBeforeBusiness( method, taskId, request);
    //子类业务数据
    ActionForward forward = super.execute(mapping, form, request, response);
    //保存后工作 和提交流程工作
    workAfterBusiness( method, taskId, processInstanceId, outcome, request);

    //清空form
    this.doLast(mapping, form, request, response);这是baseaction中的 execute方法中的几行代码  在execute之前之后都做了业务操作,有的内容是关于同一个数据的,他们不是有先后顺序么?怎么还会事务冲突? 
      

  5.   

    Row was updated or deleted by another transaction 行 被更新或删除 被其他事务