mdownes
10-26-2007, 03:20 PM
We are performing data access as follows:
We are using SQL Server with stored procedures for all data access.
It is the responsibility of the stored procedure to perform the optimistic locking check.
If there is an optimistic locking failure (i.e. the object is out of date), the stored procedure returns an error code (50001).
How do I best set-up handling for the error code?
I do not want to change the existing error code handling provided by ErrorCodeExceptionTranslator and I still want the handling provided by the FallbackExceptionTranslator.
I have implemented my own IAdoExceptionTranslator (OptimisticLockingFailureExceptionTranslator) which mimics the FallbackExceptionTranslator with the addition of handling the error code and throwing an OptimisticLockingFailureException.
This works fine. However, I am unsure how to register it. I have registered it as a fallback translator programmatically within my StoredProcedure object:
OptimisticLockingFailureExceptionTranslator myTranslator = new OptimisticLockingFailureExceptionTranslator();
myTranslator.DbProvider = dbProvider;
this.AdoTemplate.ExceptionTranslator = myTranslator;
I could do this in every StoredProcedure object but ideally, I want to override the default behaviour for AdoTemplate. Also, this has only registered it as ExceptionTranslator. I really need to register it as the fallbackTranslator on the ErrorCodeExceptionTranslator. How do I do this?
We are using SQL Server with stored procedures for all data access.
It is the responsibility of the stored procedure to perform the optimistic locking check.
If there is an optimistic locking failure (i.e. the object is out of date), the stored procedure returns an error code (50001).
How do I best set-up handling for the error code?
I do not want to change the existing error code handling provided by ErrorCodeExceptionTranslator and I still want the handling provided by the FallbackExceptionTranslator.
I have implemented my own IAdoExceptionTranslator (OptimisticLockingFailureExceptionTranslator) which mimics the FallbackExceptionTranslator with the addition of handling the error code and throwing an OptimisticLockingFailureException.
This works fine. However, I am unsure how to register it. I have registered it as a fallback translator programmatically within my StoredProcedure object:
OptimisticLockingFailureExceptionTranslator myTranslator = new OptimisticLockingFailureExceptionTranslator();
myTranslator.DbProvider = dbProvider;
this.AdoTemplate.ExceptionTranslator = myTranslator;
I could do this in every StoredProcedure object but ideally, I want to override the default behaviour for AdoTemplate. Also, this has only registered it as ExceptionTranslator. I really need to register it as the fallbackTranslator on the ErrorCodeExceptionTranslator. How do I do this?