DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Thomas has posted 33 posts at DZone. View Full User Profile

Make @Service Annotated Spring Bean Method Calls Transactional

04.16.2010
| 2982 views |
  • submit to reddit
        
  <tx:advice id="txAdvice">
    <tx:attributes>
      <tx:method name="*" propagation="SUPPORTS" read-only="true" />
    </tx:attributes>
  </tx:advice>
  
  <aop:config>
    <!-- the execution of every methods of every @Service annotated Spring bean -->
    <aop:pointcut id="withinServiceAnnotatedClass" expression="@within(org.springframework.stereotype.Service)" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="withinServiceAnnotatedClass"/>
  </aop:config>