1,接口式编程,使用接口和sql映射文件进行绑定,
2,每一个sqlSession代表一次与数据库的会话,用完必须关闭,
3,sqlSession和connection都是非线程安全的,每次使用都要创建一个新的对象,不要放到全局变量中
4,mapper接口没有实现类,但mybatis会为接口生成一个代理对象,(将接口和sql映射文件进行绑定)
sqlSession.getMapper(接口的全类名);
5,两个重要的配置文件,全局配置文件,sql映射文件
6,关于范围和生命周期
重要 Object lifecycle and Dependency Injection Frameworks
Dependency Injection frameworks can create thread safe, transactional SqlSessions and mappers and inject them directly into your beans so you can just forget about their lifecycle. You may want to have a look at MyBatis-Spring or MyBatis-Guice sub-projects to know more about using MyBatis with DI frameworks.