MyBatis_Overview_hehe.employment.over.29.1

29.1 Correspondence between the three-tier architecture and the ssm framework

  • What is a frame
    • Framework is the whole or part of the systemReusable design, Expressed asA group of abstract components and component instancesThe method of interaction; another definition considers that a framework is an application skeleton that can be customized by application developers. The former is from the application side and the latter is the definition given from the purpose side.
    • In short, a framework is actually a semi-finished product of a certain application, a set of components for you to choose to complete your own system. Simply put, you use the stage set up by others and you do the performance. Moreover, the framework is generally mature and constantly upgraded software.
  • Problems to be solved by the framework
    • The most important problem to be solved by the framework is the problem of technology integration. In the J2EE framework, there are a variety of technologies. Different software companies need to choose different technologies from J2EE, which makes the final application of software companies. Relying on these technologies, the complexity of the technology itself and the risks of the technology will directly impact the application. The application is the core of the software enterprise and the key to competitiveness. Therefore, the application's own design and specific implementation technology should be decoupled. In this way, the research and development of software companies will focus on the design of the application, rather than the specific technical implementation. The technical implementation is the underlying support of the application, and it should not directly affect the application.
    • The framework is generally in the middle layer between the low-level application platform (such as J2EE) and the high-level business logic.
  • Correspondence between three-tier architecture and ssm framework
    Insert picture description here

29.2 Problem analysis of jdbc operation database

  • Frequent database link creation and release cause waste of system resources and affect system performance. If you use a database connection pool, you can solve this problem.
  • The sql statement is hard-coded in the code, which makes the code unsuitable for maintenance. The actual application of sql may change greatly, and the sql change needs to change the java code.
  • Using preparedStatement
    to pass parameters to the occupied position symbol is hard-coded, because the where condition of the SQL statement is not necessarily, it may be more or less, and the code must be modified to modify the sql, and the system is not easy to maintain.
  • The result set is hard-coded (query column names), sql changes lead to changes in parsing code, and the system is not suitable for maintenance. It is more convenient to encapsulate database records into pojo objects for parsing.

29.3 Overview of MyBatis Framework

  • mybatis is an excellentJava-based persistence layer framework, It encapsulates jdbc inside, so that developers only need to pay attention to sql statement itself, Without having to spend energy to deal with the complicated process of loading drivers, creating connections, creating statements and so on.
  • mybatis pass xml or annotationTo be executedVarious statementsConfigured and passed Dynamic parameters of sql in java object and statementPerform mapping generationThe final executed sql statement, And finally by mybatis framework executes sql And map the result to java objectAnd return.
  • The ORM idea is used to solve the problem of entity and database mapping, encapsulate jdbc, shield the details of the underlying access of jdbc api, so that we can complete the persistence operation of the database without dealing with jdbc api.
  • SNAKE:
    • Object Relational Mapping
    • It is to associate the attributes of the database table and the entity class to keep the field names consistent.

Guess you like

Origin blog.csdn.net/qq_44686266/article/details/113975422