没用过,希望哪位给个例子,谢谢

解决方案 »

  1.   

    就算在service层开启事务管理...而不是Dao层
      

  2.   

    配置式的,注入式的都行,只要加在service层。具体怎么做网上搜吧,很多的。
      

  3.   

    看看我列子吧,
    http://download.csdn.net/detail/zuxianghuang/4158479
      

  4.   

    通过AOP
    <bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sf" />
    </bean> <aop:config>
    <aop:pointcut id="bussinessService"
    expression="execution(public * com.bjsxt.registration.service.*.*(..))" />对什么类加事物
    <aop:advisor pointcut-ref="bussinessService"
    advice-ref="txAdvice" />
    </aop:config> <tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
    <tx:method name="exists" read-only="true" />
    <tx:method name="add*" propagation="REQUIRED"/>
    这里就是控制事务,add*,表示对add方法加事物
    </tx:attributes>
    </tx:advice>