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 java.lang.Object implements org.springframework.dao.support.PersistenceExceptionTranslatorDefault exception translator. Translates MyBatis SqlSession returned exception into a SpringDataAccessExceptionusing Spring'sSQLExceptionTranslatorCan loadSQLExceptionTranslatoreagerly or when the first exception is translated.- Author:
- Eduardo Macarron
-
-
Constructor Summary
Constructors Constructor Description MyBatisExceptionTranslator(java.util.function.Supplier<org.springframework.jdbc.support.SQLExceptionTranslator> exceptionTranslatorSupplier, boolean exceptionTranslatorLazyInit)Creates a newPersistenceExceptionTranslatorinstance with specifiedSQLExceptionTranslator.MyBatisExceptionTranslator(javax.sql.DataSource dataSource, boolean exceptionTranslatorLazyInit)Creates a newPersistenceExceptionTranslatorinstance withSQLErrorCodeSQLExceptionTranslator.
-
Method Summary
Modifier and Type Method Description org.springframework.dao.DataAccessExceptiontranslateExceptionIfPossible(java.lang.RuntimeException e)
-
-
-
Constructor Detail
-
MyBatisExceptionTranslator
public MyBatisExceptionTranslator(javax.sql.DataSource dataSource, boolean exceptionTranslatorLazyInit)Creates a newPersistenceExceptionTranslatorinstance 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(java.util.function.Supplier<org.springframework.jdbc.support.SQLExceptionTranslator> exceptionTranslatorSupplier, boolean exceptionTranslatorLazyInit)Creates a newPersistenceExceptionTranslatorinstance with specifiedSQLExceptionTranslator.- Parameters:
exceptionTranslatorSupplier- Supplier for creating aSQLExceptionTranslatorinstanceexceptionTranslatorLazyInit- if true, the translator instantiates internal stuff only the first time will have the need to translate exceptions.- Since:
- 2.0.3
-
-