Spring + Plain JDBC + Transaction Management
I am trying to use transaction management with Spring and Plain JDBC(not JDBC template provided in the Spring jar).
But due to some reason the Roll back is not happening.
Here' my application Context
<?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schem...ing-tx-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schem...ng-jee-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<bean id="myImpl" class="com.my.api.myImpl">
<property name="myServices" ref="myServices" />
</bean>
<bean id="myServices" class="com.my.services.myServicesImpl">
<property name="myDAO" ref="myDAO" />
</bean>
<!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
bean below) -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- the transactional semantics... -->
<tx:attributes>
<!-- all methods starting with 'get' are read-only -->
<tx:method name="get*" read-only="true" />
<!-- other methods use the default transaction settings (see below) -->
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<!-- ensure that the above transactional advice runs for any execution of
an operation defined by the myService interface -->
<aop:config>
<aop:pointcut id="myServiceOperation"
expression="execution(* com.my.services.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="myServiceOperation" />
</aop:config>
<bean id="myDAO" class="com.my.dao.myDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- <tx:jta-transaction-manager /> -->
<!-- <jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/MySqlDS"
/> -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://172.16.175.12:3306/my" />
<property name="username" value="root" />
<property name="password" value="****" />
</bean>
<!-- <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
<property name="transactionManagerName" value="java:/TransactionManager"/>
<property name="userTransactionName" value="java:comp/UserTransaction"> </property>
</bean> -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
</bean>
</beans>