参考:http://blog.csdn.net/rootsuper/article/details/8537498
Mybatis原理:
1、根据sqlMapConfig.xml config.xml配置生成sqlSessionFactory2、sqlSessionFactory获取SqlSession
3、根据sqlId查找MappedStatement,根据入参解析MappedStatement对象,得到最终要执行的sql
4、执行sql,最后关闭sqlSession
优点:
sql自己编写,可以一定程度上保证性能
解除sql与程序代码的耦合 - ORM工具的使命
缺点:
数据库可移植些差
编写sql工作量大
Mybatis分层(从http://blog.csdn.net/rootsuper/article/details/8537498转载):
1、基础支撑
2、接口定义
3、数据处理