I\'m using Hibernate + spring + @Transactional
annotations to handle transactions in my application.
Transaction manager is declared as follows:
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>
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
.