Skip to content

Instantly share code, notes, and snippets.

@daveRanjan
Last active November 3, 2016 13:42
Show Gist options
  • Save daveRanjan/44afe1775b66567ca5a043e32738066d to your computer and use it in GitHub Desktop.
Save daveRanjan/44afe1775b66567ca5a043e32738066d to your computer and use it in GitHub Desktop.
transaction-rollback.
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"
default-autowire="byName">
<aop:config>
<aop:pointcut id="serviceOperation"
expression="execution(* com.xxxxx.business.*.*Service.*(..))" />
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="search*" read-only="true" />
<tx:method name="fetch*" read-only="true" />
<tx:method name="check*" read-only="true" />
<tx:method name="update*" read-only="false"
rollback-for="com.xxxxxx.exception.ServiceException" />
<tx:method name="add*" read-only="false"
rollback-for="com.xxxxxx.exception.ServiceException" />
<tx:method name="save*" read-only="false"
rollback-for="com.xxxx.exception.ServiceException" />
<tx:method name="*" rollback-for="com.xxxxx.exception.ServiceException" />
</tx:attributes>
</tx:advice>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/datasource</value>
</property>
</bean>
</property>
<property name="defaultTransactionIsolationName" value="TRANSACTION_READ_COMMITTED"></property>
</bean>
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" >
<bean
class="org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter" >
<property name="targetDataSource" ref="dataSource" />
<property name="isolationLevelName" value="ISOLATION_READ_COMMITTED" />
</bean>
</property>
</bean>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment