Spring宣言式事務XML配置


Spring宣言式事務機能はSpringで一番多く使われている機能の一つです.確かにこの機能はデータベースの操作を大幅に簡略化しました.現在Springでサポートされている声明式事務には二つの構成があります.一つはXML配置方式、もう一つは注釈方式です.開発で一番よく使われているのはXMLの配置です.
PROPAAGATION_REQUIREDは現在のトランザクションを使用して、現在のトランザクションがない場合、新しいトランザクションを開始します.(常用)
<!-- spring    TransactionManager    -->
	<bean id="txManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
   <tx:advice id="txAdvice" transaction-manager="txManager">
       <tx:attributes>
          <!--  get      -->
          <tx:method name="get*" read-only="true"/>
          <!--      propagation="REQUIRED"--> 
          <tx:method name="*" propagation="REQUIRED" />
       </tx:attributes>
   </tx:advice>
   
   <!--        ,      Impl      spring.jar  aspectJweaver.jar -->
   <aop:config >
      <aop:pointcut id="pcut" expression="execution(* com.allen.admin.service.impl.*.*(..))"/>
         <!--   pointcut     txAdvice               --> 
      <aop:advisor advice-ref="txAdvice" pointcut-ref="pcut"/>
   </aop:config>