mybatis学习(一) mybatis框架的特性

mybatis 的源代码地址是https://github.com/mybatis/mybatis-3/ 以及相关文档

All the information i get from http://www.mybatis.org/mybatis-3/index.html

MyBatis SQL Mapper Framework for Java

The MyBatis SQL mapper framework makes it easier to use a relational database with object-oriented applications.

MyBatis couples objects with stored procedures or SQL statements using a XML descriptor or annotations.

Simplicity is the biggest advantage of the MyBatis data mapper over object relational mapping tools.

4 important Object

1. SqlSessionFactoryBuilder

2. SqlSessionFactory

Once created, the SqlSessionFactory should exist for the duration of your application execution.

the best scope of SqlSessionFactory is application scope

3. SqlSession

Each thread should have its own instance of SqlSession

Instances of SqlSession are not to be shared and are not thread safe. Therefore the best scope is request or method scope

Upon receiving an HTTP request, you can open a SqlSession, then upon returning the response, you can close it

4. Mapper Instance

Mappers are interfaces that you create to bind to your mapped statements

上一篇:map与hash_map使用与对比


下一篇:《BI那点儿事》数据仓库建模:星型模式、雪片模式