Hi,
I'm quite stuck with the following problem:
When the database throws an SqlException, f.i. because of a unique key constraint violation, this causes an UnexpectedRollbackException in Spring TransactionInterceptor.
This is problematic because the original causal exception gets lost. This means that it is very hard to track bugs and to handle exceptions correctly.
It may be that this problem has something to do with our appserver but I'd appreciate feedback that points out the way this kind of exception should be handled by the Spring transactioninterceptor. If that is clear to me I can point out the problem in the correct way to my appserver vendor.
Where should a unique constraint violation SqlException be handled in org.springframework.transaction.interceptor.Transa ctionInterceptor?
In our case it bubbles up at the statement marked *4*
We're using Spring 1.2.6 declarative transactionhandling. (org.springframework.transaction.interceptor.Trans actionInterceptor)Code://from Spring TransactionInterceptor public Object invoke(MethodInvocation invocation) throws Throwable { //snip comment Class targetClass = (invocation.getThis() != null) ? invocation.getThis().getClass() : null; // Create transaction if necessary. TransactionInfo txInfo = createTransactionIfNecessary(invocation.getMethod(), targetClass); Object retVal = null; try { //snip comment retVal = invocation.proceed(); //*1* } catch (Throwable ex) { // target invocation exception doCloseTransactionAfterThrowing(txInfo, ex); // *2* throw ex; } finally { doFinally(txInfo); //*3* } doCommitTransactionAfterReturning(txInfo); //*4* return retVal; }
The appserver Oracle AS 10.1.2 provides the TransactionManager.
Toplink 10.1.2 provides ORM and taps into the appserver transactionmanager.


Reply With Quote