`
tanglong8848
  • 浏览: 67398 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Struts2保存更新程序走完数据库不更新

 
阅读更多
一般情况是事务没有提交,先查看spring 配置
applicationContent.xml
 <!-- 事务配置 -->
	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
	<aop:config>
        <aop:pointcut id="allManagerMethod" expression="execution (* *..service.*.*(..))"/>
     	<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
    </aop:config>
     
	<tx:advice id="txAdvice" transaction-manager="txManager">
		<tx:attributes>
			<tx:method name="add*" propagation="REQUIRED"/>
			<tx:method name="save*" propagation="REQUIRED"/>
			<tx:method name="modify*" propagation="REQUIRED"/>
			<tx:method name="update*" propagation="REQUIRED"/>
			<tx:method name="del*" propagation="REQUIRED"/>
			<tx:method name="*" propagation="SUPPORTS" read-only="true" />
		</tx:attributes>
	</tx:advice>
	<tx:annotation-driven transaction-manager="txManager" />

1、确保sevice命名与事务规则一致 如: addUser()   updateUser()  
2、可以强制提交事务,service接口的实现类加上注解@Transactional

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics