<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">    <property name="sessionFactory" ref="sessionFactory"></property></bean>加@Transactional标签可以不?

解决方案 »

  1.   


    <tx:annotation-driven />
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">    <property name="sessionFactory" ref="sessionFactory"></property></bean>加@Transactional标签可以不?加上事务代理的配置试试<bean id="transactionService"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> 
    <property name="transactionManager"> 
    <ref local="transactionManager"/> 
    </property> 
    <property  name="target"> 
    <ref local="transactionServiceControl"/> 
    </property> 
    <property  name="transactionAttributes"> 
    <props> 
    <prop key=”insert*”>PROPAGATION_REQUIRED,-Exception</prop> 
    <prop key=”update*”>PROPAGATION_REQUIRED,-Exception</prop> 
    <prop key=”*”>PROPAGATION_REQUIRED,readOnly</prop> 
    </props> 
    </property> 
    </bean>先不加-Exception试试,如果不行就加上-Exception,指定如果方法抛出Exception或它的子类,事务会自动回滚。可以用逗号分隔多个回滚规则。"-"前缀强制回滚。
      

  2.   

    注意你的aop一定要切到你的方法。
    你好像用的tx的方式、还是注解!那这样试试:@Transactional注解: 
    你可以指定传播、隔离级别、超时以及允许和不允许的异常。 
    @Transactional注解的属性: 
    propagation:指定事务定义中使用的传播 
    isolation:设定事务的隔离级别 
    timeout:指定事务的超市(秒) 
    readOnly:指定事务的超时 
    noRollbackFor:目标方法可抛出的异常所构成的数组,但通知仍会提交事务 
    rollbackFor:异常所构成的数组,如果目标方法抛出了这些异常,通知就会回滚事务
      

  3.   

    公布答案:因为使用了MyISAM表。。
    感谢其他论坛网友的解答,。
      

  4.   


    我去,MyISAM就不支持事务......
      

  5.   


    我去,MyISAM就不支持事务......恩,好处是借着这个机会,详细阅读了spring和hibernate相关的源代码了解了内部的工作流程虽然最后的原因很狗血