|
From: <jue...@we...> - 2004-06-30 13:34:33
|
A useful extension, indeed! Including a CannotAcquireLockException would make sense, I guess, = including the default mapping to ORA-54. I agree regarding restricting mappings to DataAccessException. This = would keep things clear from the perspective of calling code. Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Rod Johnson Sent: Wednesday, June 30, 2004 3:27 PM To: spr...@li... Subject: Re: [Springframework-developer] Added custom sql error code translation Thanks Thomas, I think this is a really useful feature. It makes Spring JDBC uniquely extensible AFAIK. In previous projects, I've often used a CannotAcquireLockException for SELECT FOR UPDATE NOWAIT usage (ORA-54). I think that may be an = important enough usage to justify including such an exception and the necessary mapping in the framework... Btw, I'm inclined to think that allowing mapping to anything other than DataAccessException would be unwise. It would implicitly change the = possible behaviour of all JDBC usage. Having a catch(DataAccessException) block currently guarantees picking up any exceptions; it no longer would. And = it's not like people are *forced* to catch exceptions they're not interested = in. Rgds Rod ----- Original Message ----- From: "Thomas Risberg" <tho...@tr...> To: <spr...@li...> Sent: Wednesday, June 30, 2004 2:18 PM Subject: [Springframework-developer] Added custom sql error code = translation > I have added new feature for specifying custom translations in the > sql-error-codes.xml: > > <bean id=3D"Oracle" class=3D"org.springframework.jdbc.support.SQLErrorCodes"> > <property > name=3D"badSqlGrammarCodes"><value>900,903,904,917,936,942,17006</value><= /prop erty> > <property > name=3D"dataIntegrityViolationCodes"><value>1,1400,1722,2291</value></pro= perty > > <property name=3D"customTranslations"> > <list> > <bean > = class=3D"org.springframework.jdbc.support.CustomSQLErrorCodesTranslation"= > > <property name=3D"errorCodes"><value>942</value></property> > <property > name=3D"exceptionClass"><value>com.mycompany.test.MyCustomException</valu= e></p roperty> > </bean> > </list> > </property> > </bean> > > The custom exception class must currently be a subclass of > DataAccessException - I'm considering allowing any runtime exception > unless someone objects to that. Right now there is support for the > following constructors (String), (String, Throwable), (String, > SQLException), (String, String, Throwable) and (String, String, > SQLException). If there are two String parameters, the first one = gets > the task and the second one gets the sql that was used. If there is > only one String, it gets the task and the sql concatenated. This is > consistent with the current DataAccessException usage. > > I have added SQLErrorCodes tests and I am still working on the > SQLErrorCodeExceptionTranslator tests - I will commit them later today > or tomorrow. > > The order of translation is now: > 1. call to customTranslate overridden method > 2. custom translations (your own exception) specified in customized > sql-error-codes.xml (!! NEW Feature !!) > 3. translation of error codes (standard 5 categories) in customized > sql-error-codes.xml > 4. standard translation of codes in standard sql-error-codes.xml > 5. fallback on sql state translation > > Thomas > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 -=20 digital self defense, top technical experts, no vendor pitches,=20 unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |