public class MyBatisExceptionTranslator extends Object implements org.springframework.dao.support.PersistenceExceptionTranslator
DataAccessException
using Spring's
SQLExceptionTranslator
Can load SQLExceptionTranslator
eagerly or when the first exception is
translated.Constructor and Description |
---|
MyBatisExceptionTranslator(DataSource dataSource,
boolean exceptionTranslatorLazyInit)
Creates a new
PersistenceExceptionTranslator instance with SQLErrorCodeSQLExceptionTranslator . |
MyBatisExceptionTranslator(Supplier<org.springframework.jdbc.support.SQLExceptionTranslator> exceptionTranslatorSupplier,
boolean exceptionTranslatorLazyInit)
Creates a new
PersistenceExceptionTranslator instance with specified SQLExceptionTranslator . |
Modifier and Type | Method and Description |
---|---|
org.springframework.dao.DataAccessException |
translateExceptionIfPossible(RuntimeException e) |
public MyBatisExceptionTranslator(DataSource dataSource, boolean exceptionTranslatorLazyInit)
PersistenceExceptionTranslator
instance with SQLErrorCodeSQLExceptionTranslator
.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.public MyBatisExceptionTranslator(Supplier<org.springframework.jdbc.support.SQLExceptionTranslator> exceptionTranslatorSupplier, boolean exceptionTranslatorLazyInit)
PersistenceExceptionTranslator
instance with specified SQLExceptionTranslator
.exceptionTranslatorSupplier
- Supplier for creating a SQLExceptionTranslator
instanceexceptionTranslatorLazyInit
- if true, the translator instantiates internal stuff only the first time will have the need to translate
exceptions.public org.springframework.dao.DataAccessException translateExceptionIfPossible(RuntimeException e)
translateExceptionIfPossible
in interface org.springframework.dao.support.PersistenceExceptionTranslator
Copyright © 2010–2020 MyBatis.org. All rights reserved.