No rollback only for transaction when exception occurs in submethod No rollback only for transaction when exception occurs in submethod spring spring

No rollback only for transaction when exception occurs in submethod


Create another annotation, e.g. @NoRollbackTransactional, something like:

@Transactional(noRollbackFor = RuntimeException.class)public @interface NoRollbackTransactional {}

And use this on your methods. On the other hand I agree with Donal's comment, you should revise your transaction scopes, imho it is generally not a good idea to call @Transactional from another @Transactional.


You may also need to turn off globalRollbackOnParticipationFailure.

I had this problem when I had an independent transaction within a surrounding transaction. When the independent transaction failed, it also failed the surrounding transaction.

Turning off the participation flag solved this for me:

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">    <property name="globalRollbackOnParticipationFailure" value="false" />    <property name="sessionFactory" ref="sessionFactory" /></bean>