spring-framework / org.springframework.dao.support / PersistenceExceptionTranslationInterceptor / setAlwaysTranslate

setAlwaysTranslate

open fun setAlwaysTranslate(alwaysTranslate: Boolean): Unit

Specify whether to always translate the exception ("true"), or whether throw the raw exception when declared, i.e. when the originating method signature's exception declarations allow for the raw exception to be thrown ("false").

Default is "false". Switch this flag to "true" in order to always translate applicable exceptions, independent from the originating method signature.

Note that the originating method does not have to declare the specific exception. Any base class will do as well, even throws Exception: As long as the originating method does explicitly declare compatible exceptions, the raw exception will be rethrown. If you would like to avoid throwing raw exceptions in any case, switch this flag to "true".