MyBatis Profile - semi-automatic persistence layer framework (SQL mapping framework) || supports custom sql

Introduction to MyBatis

1, MyBatis; interacting with the database; layer frame (SQL mapping framework) persistence ;

1), from the original JDBC ----- DbUtils (QueryRunner) ------- the JdbcTemplate ---- xxx; unused

         Called tool ;

          Some simple package features: Tools

          Frame: one area of ​​the overall solution;

          Caching, exception handling issues to consider, consider some of the fields mapping problem. . .


No native JDBC:

          1), the trouble;

          2), SQL statement is hard-coded in the program ; coupling (java coding layer and a database coupled) ;


 2), the frame interact with the database Hibernate- (ORM frame)  (various frameworks, automatic frame)

                 ORM (Object Relation Mapping) object-relational mapping;

@Table("t_employee")

class Employee{

          private Integer empId;

          private String empName;

}

session.get("1",Employe.class);

Disadvantages:

     1), custom sql;

     2)、HQL;SQL;

     3), full-frame mapping; difficult field mapping part ; do;


Note: It is best to have a framework could support custom SQL , but also powerful; sql do not be hard-coded in java file (resulting in maintenance modify them too much trouble);



1), MyBatis will be important steps can be extracted manually customize, other steps automation;

2), important steps are written in the configuration file (Vindication);

3), completely solve the optimization problem of the database ;

. 4), MyBatis bottom is a simple package of native JDBC ;

5), both the encoding java sql extracted out, will not function without an automated; persistence layer frame semi-automatic ;

. 6), MyBatis is a lightweight frame ;

Published 434 original articles · won praise 105 · views 70000 +

Guess you like

Origin blog.csdn.net/qq_39368007/article/details/104939302