1.概要
本稿では、異常なモジュールMyBatisの、対応する共有 exceptions
パッケージを。下図のように:
では 、「疲れMyBatisのソースコードの解析-一覧プロジェクト構造」 次のように、このモジュールを簡単に紹介は以下のとおりです。
MyBatisのは、独自のPersistenceExceptionとTooManyResultsException例外を定義します。
だけでなく、MyBatisの中に実際には exceptions
次のようにアンダークラッド異常、他のパッケージで、また全体のクラス図異常です。
以下に、我々は過去に見られる一つのパッケージの異常によって1を見てください。
2. exceptions
パッケージ
2.1 IbatisException
org.apache.ibatis.exceptions.IbatisException
RuntimeExceptionクラス、基底クラスのiBATIS例外を実現。コードは以下の通りであります:
|
- 实际上,IbatisException 已经在 2015 年被废弃,取代它的是 PersistenceException 类。
2.2 PersistenceException
org.apache.ibatis.exceptions.PersistenceException
,继承 IbatisException 类,目前 MyBatis 真正的异常基类。代码如下:
public class PersistenceException extends IbatisException { |
2.2.1 ExceptionFactory
org.apache.ibatis.exceptions.ExceptionFactory
,异常工厂。代码如下:
public class ExceptionFactory { |
2.3 TooManyResultsException
org.apache.ibatis.exceptions.TooManyResultsException
,继承 PersistenceException 类,查询返回过多结果的异常。期望返回一条,实际返回了多条。代码如下:
public class TooManyResultsException extends PersistenceException { |
3. parsing
包
3.1 ParsingException
org.apache.ibatis.parsing.ParsingException
,继承 PersistenceException 类,解析异常。代码如下:
public class ParsingException extends PersistenceException { |
3. 其它包
实际上,我们会看到其他包,会和 parsing
包一样,都会定义其独有的异常类。但是,代码都是相同的。所以,这里就简单整理如下:
reflection
包:ReflectionExceptionlogging
包:LogExceptionbuilder
包:BuilderException、IncompleteElementExceptionscripting
包:ScriptingExceptionbinding
包:BindingExceptiontype
パッケージ:TypeExceptionsession
パッケージ:SqlSessionExceptioncache
包:CacheExceptiontransaction
包:TransactionExceptiondatasource
包:DataSourceExceptionexecutor
包:ResultMapException、ExecutorException、BatchExecutorExceptionplugin
包:PluginException