org.mybatis.spring
Class MyBatisExceptionTranslator

java.lang.Object
  extended by 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 of when the first exception is translated.

Version:
$Id$

Constructor Summary
MyBatisExceptionTranslator(DataSource dataSource, boolean exceptionTranslatorLazyInit)
          Creates a new DataAccessExceptionTranslator instance.
 
Method Summary
 org.springframework.dao.DataAccessException translateExceptionIfPossible(RuntimeException e)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyBatisExceptionTranslator

public MyBatisExceptionTranslator(DataSource dataSource,
                                  boolean exceptionTranslatorLazyInit)
Creates a new DataAccessExceptionTranslator instance.

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.
Method Detail

translateExceptionIfPossible

public org.springframework.dao.DataAccessException translateExceptionIfPossible(RuntimeException e)

Specified by:
translateExceptionIfPossible in interface org.springframework.dao.support.PersistenceExceptionTranslator


Copyright © 2010-2013 MyBatis.org. All Rights Reserved.