Hello ,
I am trying spring trnasaction management for my code. I am using spring jdbc and I call mmutiple insert /update in one method. I want to wrap this method inside transaction support so that commit/rollback should happen in whole.
To test I am throwing an exception but I see that no rollback is happening . Please suggest what is going wrong in configuration.
Here is my spring configuration file
Here is my source codeCode:<!-- this is the service object that we want to make transactional --> <bean id="ReactantResourceService" class="com.X.X.ReactantResource"/> <tx:annotation-driven transaction-manager="txManager" /> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="reactantDataSource" /> </bean>
My method is executing successfully and create and update methods are executing successfully and even after throwing exception the data is not rolled back.Code:package com.X.X; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionSynchronizationManager; @Path("/test") @Transactional(readOnly = true) public class ReactantResource { //other code @POST @Path("") @Consumes("multipart/form-data") @Produces("application/xml") @Transactional(propagation=Propagation.REQUIRED, readOnly=false,rollbackFor = Exception.class) public List<Reactant> createandUpdate ( @HeaderParam(SGCConstants.req_UserIDKey) String userID, MultipartFormDataInput input) throws SGCExceptions, IOException { assert TransactionSynchronizationManager.isActualTransactionActive(); //other create/update code reactantList = create(reactantClass, inputSD); rcDAO.update(reactantClass,reactantList.size()); if(true) throw new IOException("testing txn"); return reactantList; } }
Is there any misconfiguration ?


Reply With Quote