Since you are already using a proxy, this shouldn't be that hard. Basically you need to implement your own interception around advice which catches and retries the operation. See here
You would make sure this advice is wrapped around the transactional interceptor so the transaction gets rolled back before you retry the operation. It would look something like this:
Code:
public class RetryIntercetpor
implements MethodInterceptor {
private int retry = 0; // Defaults to no retries, bombs out on first failure.
public void setRetry(int retry) {
this.retry = retry;
}
Object invoke(MethodInvocation invocation) throws Throwable {
for (int i = 0; i < retry; i++) {
try {
return invocation.proceed();
}
catch (StaleConnectionException e) {
// Escape out of # of retries has been reached
if (i >= retry)
throw e;
}
}
}
}