Mybatis learning - initial MyBatis

What is MyBatis framework?

  MyBatis framework is an ORM (object-relational mapping both) framework.

What is ORM framework?

  In order to solve a technical data between object oriented relational database do not match, it is described by Java objects and relationships between the database tables mapping relationship will automatically Java application object persistence to a relational database table,

  Benefits Mapping: Mapping of operations and objects appearances can operate table, do not need direct access to the underlying database.

        

 

  Use ORM framework, application no direct access to the underlying database, but in the object-oriented approach to working with persistent objects, ORM framework will be converted into the underlying operation of these databases through SQL operation mappings.

MyBatis advantages:

  Solves the data type matching between the object-oriented and relational databases, MyBatis layer is in the Dao.

MyBatis and Spring in the template template difference:

  Template Spring template is the SQL statement written in Java code, each time modifying the SQL statement to be recompiled, but in Mybatis in, Sql statement is written in the configuration file, modify the SQL statement so there is no need to re compile once.

Use MyBatis:

  Use Mybatis framework is very simple, only we need to introduce the core package to MyBatis in the application.

Mybatis program development steps:

  1. Create a table corresponding to the class.

  2. Configuration file mapping (mapper each profile corresponds to a table in the database), can be written in the CRUD label mapping file inside.

  3. Configure config.xml Tags: acquiring JDBC data source environment, adding a mapping file <mappers>.

  4. Test categories: reading the configuration file, configured to obtain the session factory instance, is configured to create the session object.

Guess you like

Origin www.cnblogs.com/zhilili/p/11577641.html