develog

[Java] @Transactional, tx:advice MIX 본문

Dev/Java

[Java] @Transactional, tx:advice MIX

냐옴 2014. 10. 7. 10:54

Mixing Spring AOP Declarative Transaction with @Transactional

https://gist.github.com/rponte/3181934


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 

http://www.springframework.org/schema/context 

http://www.springframework.org/schema/context/spring-context-3.0.xsd 

http://www.springframework.org/schema/tx 

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 

http://www.springframework.org/schema/aop 

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

 

<context:annotation-config />

<context:component-scan base-package="br.com.triadworks" />

<tx:annotation-driven order="1" />

 

<tx:advice id="txAdvice">

<tx:attributes>

<!-- all methods starting with 'get' are read-only -->

<tx:method name="find*" read-only="true" />

<tx:method name="count*" read-only="true" />

<tx:method name="get*" read-only="true" />

<tx:method name="busca*" read-only="true" />

<tx:method name="lista*" read-only="true" />

<!-- other methods use the default transaction settings (see below) -->

<tx:method name="*" propagation="REQUIRED" />

</tx:attributes>

</tx:advice>

<aop:config>

<aop:pointcut id="serviceMethods"

expression="execution(* br.com.syspdv.triadworks..*.*(..)) 

and not @annotation(org.springframework.transaction.annotation.Transactional)" />

<aop:advisor order="2" advice-ref="txAdvice"

pointcut-ref="serviceMethods" />

</aop:config>

</beans>


'Dev > Java' 카테고리의 다른 글

[Java] Map inline put  (0) 2014.11.19
[Java] Spring @Transactional explained  (0) 2014.10.07
[Java] Generics  (0) 2014.10.06
[Java] template callback return value  (0) 2014.10.01
[Java] 톰캣 설치 폴더 찾기  (0) 2014.09.24
Comments