Package
org.apache.ibatis.binding
- BindingException.java
When MapperRegistry Or MapperMethod bind interface with
target class object failed throw the Exception with exception message. - MapperMethod.java
Execute with Command pattern, behind proxy, bind the input interface with it. - MapperProxy.java
The agent, for all interface define in workspace. - MapperProxyFactory.java
To create generic class MapperProxy for all interface,
load interface’s method cache - MapperRegistry.java
Store all MapperProxyFactory in resource, mapping annotation? - package-info.java
Code
MapperMethod
1 | public class MapperMethod { |
- SqlCommand an inner static class represent the sql command
- MethodSignature interface’s method parameters
- executeForMany method used to execute commander’s command.
MapperProxy<T>
1 | public class MapperProxy<T> implements InvocationHandler, Serializable { |
- the front agent
- used to handle the mapper stuff
- record all mapper method in cache
- SqlSession from constructor, used in MapperMethod
MapperProxyFactory<T>
1 | public class MapperProxyFactory<T> { |
- used to create generic mapper proxy object
- a reference to method cache parse to MapperProxy
- new instance the agent object
MapperRegistry
1 | public class MapperRegistry { |
- record every mapper’s proxy factory
- parse mapper’s annotation?
Discuss
- Mybatis could use interface to execute sql is base on java’s
dynamic invoke. - SqlSession is come from MapperRegistry getMapper method’s
input parameter. - At last the SqlSession execute Object’s sql