spring的三种事务配置方式

  1. "transactionBase" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true" abstract="true">
  2. "transactionManager" ref="transactionManager">
  3. "transactionAttributes">
  4. "add*">PROPAGATION_REQUIRED,-Exception
  5. "update*">PROPAGATION_REQUIRED,-Exception
  6. "insert*">PROPAGATION_REQUIRED,-Exception
  7. "modify*">PROPAGATION_REQUIRED,-Exception
  8. "delete*">PROPAGATION_REQUIRED,-Exception
  9. "get*">PROPAGATION_NEVER
  10. "userDao" class="com.tristan.web.controller.dao.UserDAO">
  11. "sessionFactory" ref="sessionFactory">
  12. "userManagerBase" class="com.tristan.web.controller.service.UserManager">
  13. "userDao" ref="userDao">
  14. "userManager" parent="transactionBase">
  15. "target" ref="userManagerBase">
	
		
		
			
				PROPAGATION_REQUIRED,-Exception
				PROPAGATION_REQUIRED,-Exception
				PROPAGATION_REQUIRED,-Exception
				PROPAGATION_REQUIRED,-Exception
				PROPAGATION_REQUIRED,-Exception
				PROPAGATION_NEVER
			
		
	
	
	
		
	

	
		
	

	
		
	


第二种 tx:advice + aop:config
极大的减少了配置文件
Java代码 复制代码 收藏代码
  1. "txAdvice" transaction-manager="txManager">
  2. "delete" propagation="REQUIRED" />
  3. "update" propagation="REQUIRED" />
  4. "*" read-only="true" />
  5. "execution (* com.tristan.web.service.*.*(..))"
  6. id="services" />
  7. "txAdvice" pointcut-ref="services" />
  8. package="com.tristan.web.service" />
  9. package="com.tristan.web.dao" />

你可能感兴趣的:(java)