专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Java Exception

为什么TransactionInterceptor遇到exception就是没有回滚,是否该用RuntimeException

发布时间:2010-06-05 12:35:06 文章来源:www.iduyao.cn 采编人员:星星草

配置文件: 
    
  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
  <ref bean="forumSessionFactory" />
  </property>
  </bean>
 
  <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
  <property name="transactionManager">
  <ref bean="transactionManager"/>
  </property>
  <property name="transactionAttributes">
  <props>
  <prop key="add*">PROPAGATION_REQUIRED</prop>
  <prop key="update*">PROPAGATION_REQUIRED <prop key="delete*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
  </props>
  </property>
  </bean>
 
  <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
  <constructor-arg>
  <ref bean="transactionInterceptor"/>
  </constructor-arg>
  </bean>
 
 
  <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
  <property name="beanNames">
  <value>*Service</value>
  </property>
  <property name="interceptorNames">
  <list>
    <value>transactionInterceptor</value>
  </list>
  </property>
  </bean>
 
 
  <bean id="userService" class="com.class8.service.impl.UserServiceImpl" />
 
  tomcat能够正常启动成功...但是当userService出现java.lang.NullPointerException
  的时候事务不能回滚...发生错误 

------解决方法--------------------------------------------------------
userService出现java.lang.NullPointerException的方法名什么?
 
  把
  <prop key="add*">PROPAGATION_REQUIRED</prop>
  <prop key="update*">PROPAGATION_REQUIRED
  <prop key="delete*">PROPAGATION_REQUIRED</prop>
  <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
 
  换成
 
  <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
  <prop key="add*">PROPAGATION_REQUIRED</prop>
  <prop key="update*">PROPAGATION_REQUIRED     

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: