Advantages and disadvantages of mybatis and mybatis

Source: Internet
Author: User

Advantages and disadvantages of mybatis and mybatis

Advantages:

1. Easy to use and master.

2. SQL is written in xml to facilitate unified management and optimization.

3. Remove the coupling between SQL and program code.

4. Provides ing labels and supports orm field ing between objects and databases.

5. Provides object link ing labels and supports object link creation and maintenance.

6. Provides xml tags and supports writing dynamic SQL statements.

Disadvantages:

1. A large amount of SQL work, especially when there are many fields and many associated tables.

2. SQL depends on the database, resulting in poor database portability.

3. Because the tag id in xml must be unique, methods in DAO do not support method overloading.

4. The field ing label and object link ing label only describe the ing relationship. The specific implementation still depends on SQL. (For example, if a one-to-multiple Collection tag is configured, if the SQL statement does not include a join sub-table or query sub-tables, the objects returned after the query do not have an object relationship, that is, the Collection object is null)

5. The DAO layer is too simple, and the workload of object assembly is large.

6. Cascade update and cascade deletion are not supported.

7. debugging is not convenient when writing dynamic SQL statements, especially when the logic is complex.

8. The xml tag function for writing dynamic SQL statements is simple (even struts cannot match), so writing dynamic SQL statements is still limited and its readability is low.

9. If the primary key field is not queried, it is easy to overwrite the queried object.

10. The data types of parameters are not supported completely. (If the parameter is of the Date type, it is easy to report that no get or set method is available. You need to add @ param to the parameter)

11. It is inconvenient to use multiple parameters and is not powerful enough. (Currently, the supported methods include map, object, annotation @ param, and 012 index BITs by default)

12. The cache is improperly used and dirty data is easily generated.

 

Summary:

The advantage of mybatis is also the disadvantage of mybatis. Because mybatis is easy to use, the bottleneck of data reliability and integrity will be more dependent on the use level of SQL by programmers. The SQL statement is written in xml, which facilitates modification, optimization, and unified browsing, but has low readability, difficulty in debugging, and limits, it is impossible to splice complex dynamic SQL statements in the Code according to logic like jdbc. Mybatis provides jdbc for field ing and object link ing, which eliminates the need to assign values to objects, don't think of it as powerful as hibernate, it's simple, easy to use, and convenient to browse and modify SQL is its biggest advantage.

Mybatis is suitable for small projects and groups with low programmer capabilities. It is not recommended for medium and large projects. If hibernate is inefficient (it is actually caused by improper use, hibernate is actually not applicable to projects with high loads. It is better to directly use the jdbc simple framework (Template) provided by spring, and also supports object ing.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.