Hi,
I'm getting org.springframework.transaction.UnexpectedRollback Exception: Transaction rolled back because it has been marked as rollback-only after an org.springframework.orm.ObjectRetrievalFailureExce ption occurs.
The thing is, the transaction is marked as read-only throughPHP Code:org.springframework.orm.ObjectRetrievalFailureException: Object of class [nl.project.model.Item] with identifier [9]: not found
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:161)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy156.getSearchFacetOffers(Unknown Source)
I don't understand why I should get a rollbackexception on a read-only method? So, I got this problem to go away by setting up like soPHP Code:<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
But I'm not really sure if this is "right". Is there any good reason why a read-only transaction should trigger a rollback? Shouldn't I just set no-rollback-for any kind of Exception?PHP Code:<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true" no-rollback-for="org.springframework.orm.ObjectRetrievalFailureException"/>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
Kind regards,
Marc


Reply With Quote