i am working on the Spring "@Transactional" Annotation to handle the transaction.
@Transactional(readOnly = false,propagation=Propagation.REQUIRES_NEW,isolation=Isolation.READ_UNCOMMITTED,rollbackFor=SQLException.class)
public void updateBatch(Report a)
throws SQLException, DataAccessException { insert1();insert2(); insert3(); }
But in case
- insert1() - successfully inserts the data in table A.
- insert2() - successfully inserts the data in table b
- insert3() - throws the checked exception and does not insert data in table C
these inserts are ibatis inbuild functions to trigger the insert in DB I got the following exception
"Caused by: org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:717) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)"
And the transaction would not get rolledback i.e. insert1(),insert2() does not get rollback
Please do let me know what i am missing
sqlMapper.insert("insertAccount", account);
- Lalit Goyal