2 jpana JpanA 于 2014.04.24 10:55 提问

ssh 事务管理配置不能回滚

以下是我的配置信息

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory" />
</bean> 
<bean id="transactionBase" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
        lazy-init="true" abstract="true">
<!-- 配置事务管理器 -->            
    <property name="transactionManager" ref="transactionManager" />
<!-- 配置事务属性 -->            
    <property name="transactionAttributes">
          <props>
               <prop key="add*">PROPAGATION_REQUIRED</prop>
               <prop key="edit*">PROPAGATION_REQUIRED</prop>
               <prop key="find*">PROPAGATION_REQUIRED</prop>
               <prop key="*">PROPAGATION_REQUIRED</prop>
          </props>           
    </property>       
</bean>

<bean id="daotarget" class="JayTan.Transport.DAO.baseDAO">
    <property name="sessionFactory">
        <ref bean="sessionFactory"/>
    </property>
</bean>
<bean id="serviceTarget" class="JayTan.Transport.Service.ServerCheckTicket">
    <property name="dao">
        <ref bean="daotarget"/>
    </property>
</bean>

<bean id="service" parent="transactionBase">
    <property name="target">
        <ref bean="serviceTarget"/>
    </property>
</bean>

在action中调用如下

public String getCheckTicketMsg(){
    String strClassCode = this.getRequest().getParameter("strClasCode").toString().trim();
    String strSeatNum = this.getRequest().getParameter("id").toString().trim();
    String strTicketNum  = this.getRequest().getParameter("ticketNum").toString().trim();

    //1:查询对应的座位ID..
    Integer intSeatId = Integer.parseInt(this.checkTicketServer.queryCarSeatIdByClassNumCode(strClassCode, strSeatNum).get(0).toString().trim());
    //2:根据ID查询座位对象。
    CarSeat seatEntity = checkTicketServer.queryCarSeatEntity(intSeatId).get(0);
    //3:修改对象的信息并写入到数据库。
    seatEntity.setIsChcket(true);//检票,修改状态。。
    if(this.checkTicketServer.modfiyEntityStatus(seatEntity)){
        //准备一个检票对象,添加一些信息到数据库
        TicketSell sellEntity = (TicketSell) checkTicketServer.querySellIdByTicketNum(strTicketNum, strSeatNum).get(0);
        Integer intSellId = Integer.parseInt(sellEntity.getTicketSellId().toString().trim());
        TicketCheck cheEntity = new TicketCheck(intSellId, getCurrDateTime(), getCurrTime());

        if(checkTicketServer.addAllEntityMsg(cheEntity) > 0){

            strMsg = "OK";
        }else{
            strMsg = "NO";
        }
    }

我希望当

TicketSell sellEntity = (TicketSell) checkTicketServer.querySellIdByTicketNum(strTicketNum, strSeatNum).get(0);出错时回滚上边的
if(this.checkTicketServer.modfiyEntityStatus(seatEntity))里面的修改操作。如上配置不可行。请求高手帮忙告诉解决方法。。
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!