Hi i'm a new user, i'm using WebSphereUowTransactionManager and doesn't give errors, but the rollback is called but doesn't function.
This is my code:
context.xml
My class FinanceServiceImplCode:<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:jee="http://www.springframework.org/schema/jee" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <!-- MySql JDBC Provider --> <jee:jndi-lookup id="dataSource" jndi-name="jdbc/testJdbc" cache="true" resource-ref="true" lookup-on-startup="false" proxy-interface="javax.sql.DataSource" /> <bean id="txManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager"> </bean> <bean id="transactionServiceImpl" class="it.iad.spring.FinanceServiceImpl"> <property name="txManager" ref="txManager"/> <property name="dataSource" ref="dataSource"/> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="update*" propagation="REQUIRED" read-only="false" /> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="financeServiceOperation" expression="execution(* it.iad.spring.FinanceServiceImpl.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="financeServiceOperation" /> </aop:config> </beans>
In method updateEmployees i update some records on my db (MySql) and i throw a NullPointerException, the rollback is called but the changes on the db are permanet??Code:package it.iad.spring; import javax.sql.DataSource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.jta.JtaTransactionManager; import org.springframework.transaction.jta.WebSphereUowTransactionManager; public class FinanceServiceImpl implements FinanceService{ public void updateEmployees(String[] foo, String name) { String l = null; for(int i=0;i < foo.length;i++) template.update("update person set nome='"+name+"' where idPerson='"+foo[i]+"'"); l.charAt(12); } public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; template = new JdbcTemplate(); template.setDataSource(this.dataSource); } public void setTxManager(WebSphereUowTransactionManager txManager) { this.txManager = txManager; } private DataSource dataSource; private JdbcTemplate template; private WebSphereUowTransactionManager txManager; }
Please help me to understand what's going wrong!!!


Reply With Quote
