Mybatis persistence, persistence

Endurance of

  • Persistence data conversion mechanism is in a state between persistent and transient state.

    • Data that is stored (e.g., memory objects) to be permanently stored in the memory device (e.g., disk). Persistence is the major application in the database, or disk file, XML data files, and so on objects stored in the storage memory.
    • JDBC is a kind of persistence mechanism. File IO is also a persistence mechanism.
    • In life: the meat frozen, then thaw method when eating also. The method is also a fruit canning.
  • Why do we need persistence services? It is due to defects caused by memory itself

    • After the power failure memory data will be lost, but there are some objects that can not be lost anyway, such as bank account numbers, unfortunately, it is also no guarantee that the memory will never power down.
    • Memory too expensive compared to hard disk, CD-ROM external memory, memory prices higher two to three orders of magnitude, but also the high cost of maintaining, at least need to have the power of it. Therefore, even if the object does not need to be permanently preserved, also because of memory limitations can not always stay in the memory, it is necessary to persist the cache to external memory.

Persistence

  • What is persistence?

    • Persistence complete work block. ----> dao layer [DAO (Data Access Object) Data Access Objects]
    • In most cases especially enterprise applications, data persistence often means to save the data in memory to disk to be cured, and persistent implementation process is mostly through a variety of relational databases to complete.
    • But here's a word needs to be stressed, is the so-called "layer." For applications, data persistence is most essential component. In other words, our system already has the natural concept of "persistence"? Maybe, but maybe not the case. The reason behind the concept of a "persistence", rather than "long-lasting modules," "persistence unit", which means that our system architecture, there should be a relatively independent logic levels, monographs on data persistence implement logic.
    • In contrast with other parts of the system, this level should have a more clear and strict logical boundary. [Bluntly, it is used to operate the database exists! ]

Why Mybatis

  • Mybatis program is to help ape the data stored in the database, and fetch data from the database.
  • Jdbc conventional operation, many repeated blocks of code, such as: When the encapsulated data extracted, database connection is established and so on ..., the frame can be reduced by repeating the code, to improve development efficiency.
  • MyBatis is a semi-automated ORM framework (Object Relationship Mapping) -> object-relational mapping
  • All the things that do not Mybatis can still do it, just use it, all the realization will be more simple! Technology no ranking points, only the use of the technology level of the other people who have
  • MyBatis advantage

    • Easy to learn: itself is small and simple. We do not rely on any third party, as long as the easiest to install two jar files + configure several sql mapping files on it, easy to learn, easy to use, through documentation and source code, you can compare fully grasp its design and implementation.
    • Flexible: mybatis will not impose any influence on the design of existing applications or databases. sql written in xml, to facilitate unified management and optimization. By sql statement to meet all the needs of the operation of the database.
    • Sql release coupling program code: DAO layer by providing the data access logic and business logic separated from the system design more clearly, easier to maintain, easier unit testing. sql and the code, which enhances maintainability.
    • Providing xml tags, support the preparation of dynamic sql.

Guess you like

Origin www.cnblogs.com/wpy188/p/12375456.html