Package org.mybatis.spring
Class MyBatisExceptionTranslator
java.lang.Object
org.mybatis.spring.MyBatisExceptionTranslator
- All Implemented Interfaces:
org.springframework.dao.support.PersistenceExceptionTranslator
public class MyBatisExceptionTranslator
extends Object
implements org.springframework.dao.support.PersistenceExceptionTranslator
Default exception translator.
Translates MyBatis SqlSession returned exception into a Spring DataAccessException
using Spring's
SQLExceptionTranslator
Can load SQLExceptionTranslator
eagerly or when the first exception is
translated.
- Author:
- Eduardo Macarron
-
Constructor Summary
ConstructorDescriptionMyBatisExceptionTranslator
(Supplier<org.springframework.jdbc.support.SQLExceptionTranslator> exceptionTranslatorSupplier, boolean exceptionTranslatorLazyInit) Creates a newPersistenceExceptionTranslator
instance with specifiedSQLExceptionTranslator
.MyBatisExceptionTranslator
(DataSource dataSource, boolean exceptionTranslatorLazyInit) Creates a newPersistenceExceptionTranslator
instance withSQLErrorCodeSQLExceptionTranslator
. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.dao.DataAccessException
-
Constructor Details
-
MyBatisExceptionTranslator
Creates a newPersistenceExceptionTranslator
instance withSQLErrorCodeSQLExceptionTranslator
.- Parameters:
dataSource
- DataSource to use to find metadata and establish which error codes are usable.exceptionTranslatorLazyInit
- if true, the translator instantiates internal stuff only the first time will have the need to translate exceptions.
-
MyBatisExceptionTranslator
public MyBatisExceptionTranslator(Supplier<org.springframework.jdbc.support.SQLExceptionTranslator> exceptionTranslatorSupplier, boolean exceptionTranslatorLazyInit) Creates a newPersistenceExceptionTranslator
instance with specifiedSQLExceptionTranslator
.- Parameters:
exceptionTranslatorSupplier
- Supplier for creating aSQLExceptionTranslator
instanceexceptionTranslatorLazyInit
- if true, the translator instantiates internal stuff only the first time will have the need to translate exceptions.- Since:
- 2.0.3
-
-
Method Details
-
translateExceptionIfPossible
- Specified by:
translateExceptionIfPossible
in interfaceorg.springframework.dao.support.PersistenceExceptionTranslator
-