SQL (Structured Query Language) processing method and system based on MyBatis

By judging and writing XML files in MyBatis to parse SQL, the problem of not being able to dynamically operate XML in the existing technology is solved, dynamic loading and execution of SQL is realized, and the flexibility of business logic is improved.

CN119088843AInactive Publication Date: 2024-12-06KINCHENG BANK OF TIANJIN CO LTD

Patent Information

Application Number
CN202411578760.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2024-12-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, the XML file of MyBatis cannot be dynamically operated during business operation, resulting in the inability to dynamically load and execute SQL.

Method used

By determining whether the target SQL is in the cache, if it is not in the cache, write it to the basic XML file, and parse the target XML file using the persistence layer framework to obtain the database operation object to perform the corresponding operation.

Benefits of technology

It realizes the dynamic loading and execution of SQL by MyBatis, supports the addition, modification or removal of SQL operations at runtime, and improves the flexibility of application logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088843A_ABST
    Figure CN119088843A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of database operation, and discloses a MyBatis-based SQL (Structured Query Language) processing method and system, and the method comprises the steps: judging whether a target SQL is analyzed in a cache or not; if the target SQL is not in the cache, writing the target SQL into a basic XML file to obtain a target XML file; and analyzing the target XML file by utilizing a persistent layer framework to obtain a database operation object, and performing corresponding operation on a target database according to the database operation object. According to the method, after the target SQL is judged to be not in the cache through the cache, the target SQL is written into the basic standard XML file, the target XML file is analyzed, the database operation object is obtained, corresponding operation is executed, and therefore MyBatis dynamic loading and SQL execution are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database operation, and in particular to a MyBatis-based SQL processing method and system. Background Art

[0002] In the prior art, when defining database operations by using XML (XML: Extensible Markup Language, Chinese name is Extensible Markup Language, a simple data storage language, simplified and modified from Standard Generalized Markup Language (SGML), and a subset of Standard Generalized Markup Language) formatted coding files or annotations, XML files can only be written during business development. However, XML files cannot be dynamically operated during business operation.

[0003] Therefore the prior art still needs to be improved and enhanced. Summary of the invention

[0004] The main purpose of the present invention is to provide a SQL processing method and system based on MyBatis, aiming to solve the problem in the prior art that MyBatis cannot dynamically load and execute SQL when business is running.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions: In a first aspect, an embodiment of the present application provides a SQL processing method based on MyBatis, comprising: Determine whether the target SQL has been parsed in the cache; If it is not in the cache, writing the target SQL into a basic XML file to obtain a target XML file; The target XML file is parsed using a persistence layer framework to obtain a database operation object, so as to perform corresponding operations on the target database according to the database operation object.

[0006] In some embodiments, the step of determining whether the target SQL has been parsed in the cache further includes: If it is already in the cache, the persistence layer framework is used to perform corresponding operations on the target database according to the database operation object corresponding to the target SQL.

[0007] In some embodiments, determining whether the target SQL has been parsed in the cache includes: Compare the target mapping relationship corresponding to the target SQL and the target operation logic to see if they are different from the original mapping relationship in the cache, so as to determine whether the target SQL has been changed or added; The target SQL not included in the cache is changed or newly added.

[0008] In some embodiments, if not in the cache, comprises: If no mapping relationship exists in the cache, it is determined that the target SQL is not in the cache.

[0009] In some embodiments, if the cache is not in the memory, the method further comprises: If it is determined to be a changed SQL, the mapping relationship corresponding to the SQL before the change in the cache is deleted.

[0010] In some embodiments, the mapping relationship is a correspondence between a SQL hash value and a database operation object.

[0011] In some embodiments, the target SQL is obtained by pre-operating the business logic of the target database.

[0012] In a second aspect, an embodiment of the present application provides a SQL processing system based on MyBatis, including: The judgment module is used to judge whether the target SQL has been parsed in the cache; A writing module, used for writing the target SQL into a basic XML file if the target SQL is not in the cache, to obtain a target XML file; The parsing module is used to parse the target XML file using the persistence layer framework to obtain a database operation object, so as to perform corresponding operations on the target database according to the database operation object.

[0013] In a third aspect, an embodiment of the present application provides an intelligent terminal, comprising: a memory, a processor, a display, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the MyBatis-based SQL processing method as described above.

[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the MyBatis-based SQL processing method as described above.

[0015] Compared with the prior art, the present invention provides a MyBatis-based SQL processing method and system, the method comprising: determining whether the target SQL has been parsed in the cache; if not in the cache, writing the target SQL into a basic XML file to obtain a target XML file; parsing the target XML file using a persistence layer framework to obtain a database operation object, so as to perform corresponding operations on the target database according to the database operation object. After the present application determines that the target SQL is not in the cache through the cache, the target SQL is written into a basic XML file, and the target XML file is parsed to obtain the database operation object to perform corresponding operations, thereby realizing MyBatis dynamic loading and execution of SQL. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 A flowchart of a preferred embodiment of the SQL processing method based on MyBatis provided by the present invention; Figure 2 A schematic diagram of a process of completing database operations by default in the prior art provided by the present invention; Figure 3 A schematic diagram of completing database operations based on the MyBatis SQL processing method provided by the present invention; Figure 4 A flowchart of obtaining a target XML file in a preferred embodiment of the SQL processing method based on MyBatis provided by the present invention; Figure 5 The architectural relationship diagram of the SQL processing system based on MyBatis provided by the present invention; Figure 6 A schematic diagram of the operating environment of a preferred embodiment of the intelligent terminal provided by the present invention. DETAILED DESCRIPTION

[0018] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0019] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0020] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.

[0021] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.

[0022] In order to facilitate understanding of the embodiments of the present application, the background technology involved in the embodiments of the present invention is first introduced here.

[0023] 1. MyBatis: (MyBatis is a lightweight, semi-automatic ORM (Object Relational Mapping, which is used to implement data conversion between different types of systems in object-oriented programming languages) framework for the persistence layer) is a Java persistence layer framework used to simplify database operations. It configures and maps primitive types, interfaces, and Java POJO (POJO: Plain Ordinary JavaObject, but it generally refers to ordinary java objects that do not use Entity Beans ((Entity Bean) is a persistent data component that represents a persistent (Persistence) object stored in an external medium or an existing enterprise application system resource) as records in the database through XML or annotations. When configuring through XML, you need to complete the XML writing during the development process, and you cannot operate on the XML at runtime.

[0024] 2. MyBatis-Plus: It is an enhancement tool of MyBatis. It only enhances MyBatis without changing it. It is designed to simplify development and improve efficiency. However, MyBatis-Plus only enhances the development process and still cannot adjust the logic at runtime.

[0025] 3. MyBatis Generator: It is the official code generation tool of MyBatis. It can generate a large number of flexible XML files, but it still cannot make dynamic adjustments to the XML at runtime.

[0026] Although the above tools are very convenient and can help quickly complete business development, they cannot define some XML to complete database operations at runtime in some business demand processes.

[0027] In order to solve the above-mentioned prior art problems, the present invention provides a SQL (SQL: Structured Query Language, Chinese name is structured query language) processing method and system based on MyBatis. In the present invention, by using the cache to determine whether the target SQL is in the cache, the target SQL that is not in the cache is written into the target XML file, and the target XML file is parsed to obtain the database operation object to perform corresponding operations on the target database, thereby realizing the dynamic addition, modification or removal of SQL rows, and these SQLs can be used in real time at runtime to complete the corresponding application logic more flexibly.

[0028] The following describes the design of the SQL processing method based on MyBatis through specific exemplary embodiments. It should be noted that the following embodiments are only used to explain the technical solution of the invention and are not specifically limited: See also Figure 1 , the embodiment of the present application provides a SQL processing method based on MyBatis, including steps S100-S300: S100: Determine whether the target SQL has been parsed in the cache.

[0029] The target SQL is obtained by pre-operating the business logic of the target database. By only developing and writing the code related to the business logic of the target database, business development can be effectively simplified.

[0030] Exemplarily, the MyBatis-based SQL processing method in the embodiment of the present application is implemented based on MyBatis (persistence layer framework), and refers to the default logical functions of MyBatis. In the business logic (thread operation or business operation process) that requires operation of custom XML, self-maintained XML logic is loaded to complete the dynamic maintenance of business logic.

[0031] Furthermore, in the embodiment of the present application, a cache is pre-stored, wherein the cache stores mapping relationships between different SQL statements and corresponding Statements.

[0032] Also see Figure 2 , the default logical functions of MyBatis are implemented as follows: First, when the business logic operates the database, it will operate the Dao (Dao: Data Access Object, Chinese name is data access interface, refers to the Java interface entry for operating the database, to implement operations such as adding, deleting, checking and modifying the database) interface.

[0033] Then, during the system development process, the SQL fragment will be defined for the Dao interface and saved in XML format to obtain the XML encoding fragment. Each Dao interface corresponds to an SQL operation. You only need to write the relevant SQL fragment in the target XML file and ensure that the SQL id of the target XML file corresponds to the name of the Dao interface. Then, during the business development process, the corresponding SQL fragment can be directly executed by calling the Dao interface.

[0034] Secondly, during the system startup process, MyBatis will use dynamic proxy technology to automatically generate an implementation class for the Dao interface code after parsing the XML encoding fragment (the implementation class is to implement the content agreed in the interface), and generate a Statement (Statement is an operation object for Java to operate the database. In MySQL (MySQL is a relational database management system), Statement refers to a SQL statement, which is the basic unit of interaction with the database. When a statement is executed in MySQL, it is usually called a "Statement"), thereby automatically creating a corresponding relationship between the Dao interface and the Statement.

[0035] Furthermore, the business logic operates the Dao interface, and the implementation class will process the predetermined logic to complete the database operation. Among them, the pre-processing logic, for example: to do a database query, you need to pass in parameters, and the parameters will be filled in the variables in the SQL fragment. This parameter filling process is the pre-processing logic. The pre-processing logic here refers to any logic before the SQL fragment is judged to be actually executed.

[0036] Finally, the operation result is returned to the business logic, and the business logic continues to complete the subsequent process. Among them, the subsequent process, for example: the time data queried from the database may be a string, but it is a time object in the code, so the string is converted into an object, which is a subsequent logic. The post-logic here refers to any processing logic after the SQL fragment is executed and before the business logic obtains the final data.

[0037] However, although the content of some business logic is relatively fixed, SQL can be written during the demand assessment process. However, the content of some business logic changes a lot, such as report generation. In the case where SQL cannot be written in advance, this application defines different SQL for different business logics by developing an independent XML logic maintenance function, and writes all SQL statements in XML format, and finally as part of the target XML file content, so as to achieve real-time online definition of SQL statements. In this target XML file, any syntax logic of MyBatis official XML can be supported.

[0038] Then, please refer to Figure 3 , the implementation process of the SQL processing method based on MyBatis in this application is as follows: First, when the business logic in this application performs digital language library operations, it no longer calls the default Dao interface, but calls the repackaged operation method: the method that simulates the underlying Dao.

[0039] In the repackaging operation method, the mapping relationship in the cache is used to determine whether the target SQL is in the cache, that is, to determine whether the target SQL is newly added or changed, so as to adopt different processing methods for the target SQL. Among them, the target SQL not in the cache means that it is the target SQL that has not been loaded or parsed.

[0040] For example, in one implementation, step S100, determining whether the target SQL has been parsed in the cache, includes: S110, comparing the target SQL and the target mapping relationship corresponding to the target operation logic to see if they are different from the original mapping relationship in the cache, so as to determine whether the target SQL has been changed or added; The mapping relationship is the correspondence between the hash value of SQL and the database operation object; the mapping relationship includes: the target mapping relationship and the original mapping relationship; the target SQL that is not included in the cache is changed or newly added.

[0041] Exemplarily, when determining whether the target SQL is in the cache, the target mapping relationship corresponding to the target SQL and the target operation logic is compared with the original mapping relationship in the cache to see whether the target mapping relationship is different from the original mapping relationship, so as to determine whether the target SQL has changed or is newly added based on the comparison result, that is, if the operation logic in the original mapping relationship has changed or when the target mapping relationship is a new mapping relationship that exists in the original mapping relationship, it can be determined whether the target SQL has changed or is newly added.

[0042] Further, step S100, determining whether the target SQL has been parsed in the cache, and then further comprising: S10. If it is already in the cache, use the persistence layer framework to perform corresponding operations on the target database according to the target SQL.

[0043] Exemplarily, the business logic of the SQL operation target database is edited and bound in advance to achieve one target SQL corresponding to one business logic of the operation target database.

[0044] When determining whether the target SQL has been parsed in the cache: If it is determined that the target SQL is not in the cache, that is, the target mapping relationship exists in the original mapping relationship in the cache, that is, the target SQL has been loaded. Then, use the persistence layer framework (MyBatis) to simulate the underlying call of the interface, and use SqlSession (SqlSession is one of the core interfaces of MyBatis and the main interface for executing SQL statements. It provides various methods for interacting with the database and represents a session with the database) to operate this target SQL to perform corresponding operations on the target database, including: add, delete, modify, and query.

[0045] Please continue reading Figure 1 , S200, if it is not in the cache, write the target SQL into the basic XML file to obtain the target XML file.

[0046] Exemplarily, when determining whether the target SQL is in the cache, if it is determined that the target SQL is not in the cache, the target SQL is automatically written into the basic XML file to complete the target XML file that can be recognized by MyBatis, that is, the necessary basic elements of the basic XML file are added to the target SQL (corresponding to Figure 3 Step B. Concatenate the complete and recognizable XML), get the target XML file that can be parsed, and then parse this XML by MyBatis (corresponding to Figure 3 Step C. in the simulation application startup MyBatis loads XML process using XMLMapperBuilder to load XML) to obtain Statement for further work, thus realizing a powerful dynamic SQL syntax maintained in XML form supported by MyBatis.

[0047] For example, in one embodiment, see Figure 4 , step S200, if it is not in the cache, write the target SQL into the basic XML file to obtain the target XML file, including: S210: If the mapping relationship does not exist in the cache, it is determined that the target SQL is not in the cache; S220: Add necessary basic elements of the basic XML file to the target SQL to obtain a target XML file that can be parsed.

[0048] The necessary basic elements include basic tags, encoding, version number and other information of the basic XML file.

[0049] Exemplarily, when determining whether the target SQL is in the cache: If there is no mapping relationship in the cache, that is, there is neither the original mapping relationship nor the target mapping relationship in the cache, it can be determined that the target SQL is not in the cache.

[0050] Then, at least one necessary basic element such as XML basic tags, encoding and version number is added to the target SQL to obtain a target XML file that can be parsed.

[0051] Furthermore, if it is not in the cache, the following is also included: S2000: If it is determined that the SQL is changed, the mapping relationship corresponding to the SQL before the change in the cache is deleted.

[0052] Exemplarily, when it is determined that the operation logic of the target SQL has changed in the original mapping relationship, the mapping relationship corresponding to the SQL before the change in the cache is deleted to reduce memory usage and reduce the re-judgment of the changed mapping relationship, thereby speeding up the judgment speed.

[0053] Please continue reading Figure 1 , S300, using the persistence layer framework to parse the target XML file, obtain a database operation object, and perform corresponding operations on the target database according to the database operation object.

[0054] Demonstratively, after obtaining the target XML file that can be parsed, the logic of loading the target XML file during the MyBatis startup process is simulated, and the persistence layer framework parses the target XML file in real time to obtain the executable database operation object Statement, thereby successfully loading the user's XML into MyBatis at runtime. After that, you only need to use SqlSession to call Statement to complete the business logic.

[0055] See also Figure 5 , the embodiment of the present application provides a SQL processing system based on MyBatis, including: The judgment module 1 is used to judge whether the target SQL has been parsed in the cache.

[0056] The writing module 2 is used to write the target SQL into the basic XML file if it is not in the cache, so as to obtain the target XML file.

[0057] The parsing module 3 is used to parse the target XML file using the persistence layer framework to obtain a database operation object, so as to perform corresponding operations on the target database according to the database operation object.

[0058] Demonstratively, the SQL processing method based on MyBatis is applicable to the SQL processing system based on MyBatis. Then, the implementation process of the SQL processing system based on MyBatis is as follows: First, the mapping relationship in the cache is used to determine whether the target SQL is newly added or changed, so as to determine whether the target SQL is in the cache, that is, to determine whether the target SQL is newly added or changed.

[0059] Then, if it is determined that the target SQL is newly added or changed, the necessary basic elements of the original XML file (basic tags, encoding, version number and other information of the target XML file) are added to the target SQL to obtain a target XML file that can be parsed.

[0060] Secondly, the persistence layer framework parses the target XML file to obtain the database operation object, and performs corresponding operations such as adding, deleting, modifying and querying on the target database according to the database operation object Statement.

[0061] like Figure 6 As shown, based on the above-mentioned MyBatis-based SQL processing method, the present invention also provides a smart terminal accordingly, and the smart terminal includes a processor 10, a memory 20 and a display 30. Figure 6 Only some components of the smart terminal are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.

[0062] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip. The processor 10 may be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or at least one of other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc., and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application.

[0063] In some embodiments, the memory 20 may be an internal storage unit of the intelligent terminal, such as a hard disk or memory of the intelligent terminal. In other embodiments, the memory 20 may also be an external storage device of the intelligent terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the intelligent terminal. Further, the memory 20 may also include both an internal storage unit and an external storage device of the intelligent terminal. The memory 20 is used to store application software and various types of data installed in the intelligent terminal, such as program codes for installing the intelligent terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a computer program 40 is stored on the memory 20, and the computer program 40 can be executed by the processor 10, thereby realizing the SQL processing method based on MyBatis in the present application.

[0064] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, Chinese name: organic light-emitting diode) touch device, etc. The display 30 is used to display information on the smart terminal and to display a visual user interface. The components 10-30 of the smart terminal communicate with each other through a system bus.

[0065] In one embodiment, the steps implemented when the processor 10 executes the computer program 40 in the memory 20 can refer to the corresponding description in the above-mentioned MyBatis-based SQL processing method, which will not be repeated here.

[0066] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program 40, and when the computer program 40 is executed by a processor, the steps of the MyBatis-based SQL processing method are implemented as described above; since the steps of the MyBatis-based SQL processing method are described in detail above, they will not be repeated here.

[0067] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0068] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0069] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.

[0070] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A SQL processing method based on MyBatis, It is characterized in that include: Determine whether the target SQL has been parsed in the cache; If it is not in the cache, writing the target SQL into a basic XML file to obtain a target XML file; The target XML file is parsed using a persistence layer framework to obtain a database operation object, so as to perform corresponding operations on the target database according to the database operation object.

2. According to the MyBatis-based SQL processing method of claim 1, It is characterized in that The step of determining whether the target SQL has been parsed in the cache further includes: If it is already in the cache, the persistence layer framework is used to perform corresponding operations on the target database according to the database operation object corresponding to the target SQL.

3. According to the MyBatis-based SQL processing method of claim 1, It is characterized in that The step of determining whether the target SQL has been parsed in the cache includes: Compare the target mapping relationship corresponding to the target SQL and the target operation logic to see if they are different from the original mapping relationship in the cache, so as to determine whether the target SQL has been changed or added; The target SQL not included in the cache is changed or newly added.

4. According to the MyBatis-based SQL processing method of claim 3, It is characterized in that If not in the cache, comprising: If no mapping relationship exists in the cache, it is determined that the target SQL is not in the cache.

5. According to the MyBatis-based SQL processing method of claim 3, It is characterized in that If the cache is not in the cache, the method further includes: If it is determined to be a changed SQL, the mapping relationship corresponding to the SQL before the change in the cache is deleted.

6. According to the MyBatis-based SQL processing method of claim 4, It is characterized in that The mapping relationship is the corresponding relationship between the SQL hash value and the database operation object.

7. The MyBatis-based SQL processing method according to claim 1, It is characterized in that The target SQL is obtained by pre-operating the business logic of the target database.

8. A SQL processing system based on MyBatis, It is characterized in that include: The judgment module is used to judge whether the target SQL has been parsed in the cache; A writing module, used for writing the target SQL into a basic XML file if the target SQL is not in the cache, to obtain a target XML file; The parsing module is used to parse the target XML file using the persistence layer framework to obtain a database operation object so as to perform corresponding operations on the target database according to the database operation object.

9. A smart terminal, It is characterized in that include: A memory, a processor, a display, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the MyBatis-based SQL processing method as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, It is characterized in that A computer program is stored, and when the computer program is executed by a processor, the steps of the SQL processing method based on MyBatis as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Monad-based persistent layer composite condition query method and storage medium

    CN111125440A

  • Relational database switching method and device and electronic equipment

    CN118747202A

  • Database access method and device based on MyBatis framework

    CN118796859A

Cited By

  • Method and system for realizing efficient data storage by expanding MyBaatisPlus in semiconductor MES (Manufacturing Execution System)

    CN121434222A