Skip to content

Instantly share code, notes, and snippets.

@tsegismont
Created June 20, 2012 14:01
Show Gist options
  • Save tsegismont/2960038 to your computer and use it in GitHub Desktop.
Save tsegismont/2960038 to your computer and use it in GitHub Desktop.
Default Transaction Interception for spring @service objects
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="myDS" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<aop:config>
<aop:pointcut id="defaultServiceMethodTxPointcut"
expression="execution([email protected] * *(..))
and @within(org.springframework.stereotype.Service)
and (!@within(org.springframework.transaction.annotation.Transactional)) " />
<aop:advisor advice-ref="defaultServiceMethodTxAdvice" pointcut-ref="defaultServiceMethodTxPointcut" />
</aop:config>
<tx:advice id="defaultServiceMethodTxAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="is*" propagation="SUPPORTS" read-only="true" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<tx:method name="load*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment