An online editing method, device and equipment of dynamic SQL and medium
By editing MyBatis' dynamic SQL online and validating and parsing parameters in real time, the problem of needing to restart the application after modifying dynamic SQL has been solved. This enables real-time effects and efficient debugging, improving development efficiency and system adaptability.
Patent Information
- Application Number
- CN202411623994.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2044-11-14
AI Technical Summary
In existing technologies, MyBatis' dynamic SQL requires the application to be restarted when modified, and it cannot validate the format and parse parameters in real time, resulting in low development efficiency and difficulty in maintenance.
This provides an online editing method for dynamic SQL, including real-time syntax validation and parsing, online script debugging, saving and calling processes. It supports the writing and formatting of dynamic SQL scripts for MyBatis, and validates syntax and parses parameters in real time through the online editing interface, and executes SQL statements in the background, so that the changes take effect without restarting the application.
It enables real-time application of dynamic SQL, improves development and debugging efficiency, reduces the number of service restarts, enhances system maintainability and scalability, and supports script execution for multiple database types.
Smart Images

Figure CN119847909B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and medium for editing dynamic SQL. Background Technology
[0002] MyBatis is an excellent persistence layer framework that supports custom SQL, stored procedures, and advanced mappings. Dynamic SQL is a key feature of MyBatis. In MyBatis, dynamic SQL allows us to write conditional statements in XML mapping files, determining the specific execution content of the SQL based on runtime parameters.
[0003] Generally, MyBatis' dynamic SQL is stored in the project as files. Modifications require changing these files, replacing the original ones, and restarting the application for the changes to take effect. This process presents challenges such as the inability to validate formatting and parse script parameters in real time, dynamically set business attribute values, and perform dynamic debugging. Furthermore, with multiple iterations, the mapper content becomes increasingly large and complex, significantly reducing maintainability. Simple formatting issues frequently arise, such as incorrect tag syntax, extra commas or semicolons, or incorrect table fields, which cannot be corrected or detected promptly. Each service restart and debugging session is necessary, impacting development efficiency. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a method, apparatus, device and medium for online editing of dynamic SQL, which can edit dynamic SQL scripts online and take effect in real time without restarting the application, thereby greatly improving debugging efficiency.
[0005] In a first aspect, the present invention provides an online editing method for dynamic SQL, including a real-time syntax verification and parsing process, an online script debugging process, a saving process, and a calling process;
[0006] The real-time syntax validation and parsing process includes: providing an online editing and configuration interface that supports writing and formatting MyBatis dynamic SQL script syntax and pure SQL syntax; after the user writes the dynamic SQL script through the online editing and configuration interface and clicks parameter settings, the dynamic SQL script is validated by a pre-generated SqlSource object to ensure it conforms to MyBatis syntax; if not, a prompt is given; if yes, reflection and regular expressions are used to parse the parameter names and parameter types (parameter types mainly include strings, maps, arrays, numbers, dates, and booleans) of the dynamic SQL script in real time; then, the parameter names, parameter types, and default values are displayed on the interface; and constants or variables of the parameter types are set according to the default values, with the variables automatically changing according to changes in the business data currently being operated on by the system.
[0007] The online debugging process of the script includes: setting parameter test values, transmitting the parameter test values along with the dynamic SQL script, the parameter name, the parameter type, and the data source to the backend; the backend first verifies whether the parameter test values match the parameter type. If not, a mismatch message is displayed. If yes, the dynamic SQL script is assembled into a string according to XML format, and the string is verified to conform to XML syntax. If it does not conform, a message is displayed. If it conforms, the parameter is first set to the default value, then a custom test value is set, and the two are combined to generate a map-type input parameter object; the dynamic SQL script is used to generate the MappedStatement required for SQL execution, and then the msId corresponding to the MappedStatement and the map-type input parameter object are used to execute the dynamic script method using MyBatis; using the currently transmitted data source, the dynamic script is parsed into an SQL statement that the database can execute, the SQL statement is executed, and the SQL statement and execution result are returned to the front-end interface for display, thereby achieving the effect of online verification of the correctness of SQL syntax.
[0008] The saving process includes: after debugging, saving the dynamic SQL script to the database, then immediately refreshing the dynamic SQL script content of the current server, preloading the MappedStatement, and recording the modification time for service calls.
[0009] The invocation process includes: assembling an execution parameter map based on the executed dynamic SQL script, the configured default parameter values, and the parameter values transmitted in real time; then obtaining the data source type based on the data source of the current business execution; searching for and executing the dynamic SQL script of that data source type; if the search fails, using a general type of script for execution to achieve the effect of real-time effect.
[0010] Secondly, the present invention provides an online editing device for dynamic SQL, comprising:
[0011] Real-time syntax validation and parsing module: This module provides an online editing and configuration interface that supports writing and formatting MyBatis dynamic SQL script syntax and pure SQL syntax. After the user writes a dynamic SQL script through the online editing and configuration interface and clicks on parameter settings, the module uses a pre-generated SqlSource object to validate whether the dynamic SQL script conforms to MyBatis syntax. If not, a prompt is displayed; if yes, reflection and regular expressions are used to parse the parameter names and parameter types (parameter types mainly include strings, maps, arrays, numbers, dates, and booleans) of the dynamic SQL script in real time. The module then displays the parameter names, parameter types, and default values on the interface. Constants or variables of the parameter types are set according to the default values, and these variables automatically change based on changes in the business data being processed by the system.
[0012] The online script debugging module is used to set parameter test values. These test values, along with the dynamic SQL script, parameter name, parameter type, and data source, are transmitted to the backend. The backend first verifies whether the parameter test value matches the parameter type. If not, a mismatch message is displayed. If they match, the dynamic SQL script is assembled into a string according to XML format, and the string is verified to conform to XML syntax. If it does not conform, a message is displayed. If it does conform, the parameter is first set to its default value, then a custom test value is set, and the two are combined to generate a map-type input parameter object. The dynamic SQL script generates a MappedStatement required for SQL execution. Then, the msId corresponding to the MappedStatement and the map-type parameters are used to execute the dynamic script method using MyBatis. Using the currently transmitted data source, the dynamic script tags are parsed into SQL statements that the database can execute. The SQL statements are executed, and the SQL statements and execution results are returned to the frontend interface for display, thus achieving the effect of online verification of SQL syntax correctness.
[0013] The save module is used to save the dynamic SQL script to the database after debugging, then immediately refresh the dynamic SQL script content of the current server, preload the MappedStatement, and record the modification time for service calls.
[0014] The calling process module is used to assemble an execution parameter map based on the dynamic SQL script being executed, the configured default parameter values, and the parameter values transmitted in real time. Then, it obtains the data source type based on the data source of the current business execution, searches for the dynamic SQL script of that data source type and executes it. If the search fails, it uses a general type of script to execute, achieving the effect of real-time effect.
[0015] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect.
[0016] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.
[0017] The present invention provides one or more technical solutions, which have at least the following technical effects or advantages: Based on online editing of dynamic SQL scripts, it can take effect in real time, reduce the debugging time of developers, accelerate software iteration, and meet business needs. During the process of writing dynamic SQL, a series of auxiliary functions are provided, such as real-time validation of format and syntax, real-time parsing of parameters in dynamic SQL, script formatting, historical record viewing, and generation and dynamic loading of commonly used dynamic SQL scripts based on table structure. It also supports real-time execution of SQL based on set parameter values and selected data sources, thereby checking whether the dynamic SQL syntax is correct and whether the test execution results meet expectations, greatly facilitating the writing of dynamic SQL and significantly improving the scalability of applications. In addition, the system also supports saving dynamic SQL as scripts for different database types (such as MySQL, Oracle, DM, etc.), and can automatically select and execute different types of dynamic SQL based on different data sources during execution, providing convenience for the application in heterogeneous databases.
[0018] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0019] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0020] Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention;
[0021] Figure 2 This is a flowchart illustrating the process of writing dynamic SQL according to an embodiment of the present invention;
[0022] Figure 3 This is a flowchart of the real-time syntax verification and parsing process according to an embodiment of the present invention;
[0023] Figure 4 This is a flowchart of the online debugging process of the script in an embodiment of the present invention;
[0024] Figure 5 This is a flowchart illustrating the saving and recall processes in an embodiment of the present invention;
[0025] Figure 6 This is a schematic diagram of the device in Embodiment 2 of the present invention;
[0026] Figure 7 This is a schematic diagram of the electronic device in Embodiment 3 of the present invention;
[0027] Figure 8 This is a schematic diagram of the structure of the medium in Embodiment 4 of the present invention. Detailed Implementation
[0028] This application provides a method, apparatus, device, and medium for online editing of dynamic SQL, which allows for online editing of dynamic SQL scripts and takes effect in real time without restarting the application, thus greatly improving debugging efficiency.
[0029] The overall concept of the technical solution in this application is as follows: It proposes an online management and configuration scheme for dynamic SQL, including real-time syntax verification and parsing, online script debugging, saving, and calling processes. It possesses capabilities such as real-time format and syntax verification, real-time parameter parsing in dynamic SQL, dynamic debugging, dynamic loading, and real-time effectiveness. It can execute SQL based on set parameter values and data sources, thereby achieving the effect of checking the correctness of dynamic SQL syntax and providing a real-time preview. During execution, it can automatically select and execute different types of dynamic SQL based on different data sources. After debugging, the SQL can be saved in different database types, such as MySQL, Oracle, and DM, and during execution, it can automatically select and execute different types of dynamic SQL based on different data sources.
[0030] Example 1
[0031] like Figure 1 As shown, this embodiment provides an online editing method for dynamic SQL, including the process of writing dynamic SQL, the process of real-time syntax verification and parsing, the process of online script debugging, the process of saving, and the process of calling.
[0032] like Figure 2As shown, the dynamic SQL writing process includes: the system provides an online selection of a table, retrieves relevant information about the online table from the database, including table name, primary key, and fields; selects a pre-configured dynamic SQL script template as needed; uses FreeMarker variable substitution capabilities to replace variables in the template with relevant information from the online table; and generates dynamic SQL in batches. This method reduces repetitive work in writing common scripts and improves development efficiency. The system also supports built-in preset fields in dynamic SQL scripts, such as creator, creation time, operator, and operation time. During use, these preset fields are replaced with actual fields like creator, creation time, operator, and operation time through parameter substitution. The system can dynamically assign values to these preset fields based on the current environment data, eliminating the need for developer intervention and allowing developers to focus more on business functionality. Using preset fields also reduces script size and increases the maintainability of dynamic SQL. Furthermore, the generated dynamic SQL supports dynamic parameter parsing, parameter setting, real-time preview, and dynamic loading.
[0033] like Figure 3 As shown, the real-time syntax validation and parsing process includes: providing an online editing and configuration interface that supports the writing and formatting of MyBatis' dynamic SQL script syntax and pure SQL syntax; after the user writes the dynamic SQL script through the online editing and configuration interface and clicks parameter settings, the dynamic SQL script is validated to ensure it conforms to MyBatis syntax by pre-generating a SqlSource object. If not, a prompt is given; if yes, reflection and regular expressions are used to parse the parameter names and parameter types of the dynamic SQL script in real time. The parameter types mainly include strings, maps, arrays, numbers, dates, and booleans; then, the parameter names, parameter types, and default values are displayed on the interface; and constants or variables of the parameter types are set according to the default values, which can automatically change according to changes in the business data currently being operated by the system.
[0034] The parameter default value setting supports setting constants and variables. Constants are set according to the parameter type; for example, a string could be set to "abc", and a map type could be set to "{"name":"lilei","age":20}, etc. Variables utilize built-in variables, such as business date, current user, and organization number, with default values. Built-in variable values automatically retrieve their values based on the current business data and change automatically as the business data changes; therefore, these variable values are also called business values. This method is more flexible and reduces code size compared to setting default values directly in the SQL script.
[0035] After setting the parameter data, click "Online Script Debugging" to enter the online script debugging process. For example... Figure 4 As shown, the online script debugging process includes: setting parameter test values, transmitting the parameter test values along with the dynamic SQL script, the parameter name, the parameter type, and the data source to the backend; the backend first verifies whether the parameter test values match the parameter type. If not, a mismatch message is displayed; if yes, the dynamic SQL script is assembled into a string according to XML format, and the string is verified to conform to XML syntax. If it does not conform, a message is displayed, the dynamic SQL script is adjusted, and online debugging is restarted. If it conforms, the parameter is first set to the default value, then a custom test value is set, and the two are combined to generate a map-type input parameter object. This enables the ability to use the default value for debugging if no test value is set. The dynamic SQL script generates a MappedStatement required for SQL execution, and then MyBatis is used to execute the dynamic script method using the msId corresponding to the MappedStatement and the map-type input parameter object. Using the currently transmitted data source, the dynamic script is parsed into an SQL statement that the database can execute, the SQL statement is executed, and the SQL statement and execution result are returned to the frontend interface for display, thereby achieving the effect of online verification of SQL syntax correctness.
[0036] The saving process includes: after the dynamic SQL script is debugged online, it is saved to the database. Then, the dynamic SQL script content on the current server is immediately refreshed, and the MappedStatement is preloaded. The modification time is recorded for use by other cluster services. These services can detect changes to the dynamic SQL script and update their cache, ensuring other services can use the dynamic SQL script correctly. When saving the dynamic SQL script to the database, it is also configured as a script for different database types to support use in heterogeneous database environments, or as a general-purpose script applicable to all databases. After saving, the version record corresponding to the dynamic SQL script is also stored for historical version backtracking and one-click restoration of historical versions.
[0037] like Figure 5As shown, the calling process includes: assembling an execution parameter map based on the executed dynamic SQL script, the configured default parameter values, and the real-time transmitted parameter values; then obtaining the data source type based on the data source of the current business execution; searching for and executing the dynamic SQL script of that data source type; if the search fails, using a general type of script for execution; after finding the script to be executed, using a pre-loaded MappedStatement to execute the dynamic SQL script to achieve the effect of real-time effect.
[0038] During the execution of the dynamic SQL script, the system first verifies whether the set parameter types and the types of the parameter values passed in real time are consistent. If they are inconsistent, a prompt is displayed. This prevents index invalidation due to inconsistency and improves execution efficiency.
[0039] Example 2
[0040] Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2.
[0041] like Figure 6 As shown, this embodiment provides an online editing device for dynamic SQL, including:
[0042] like Figure 2 As shown, the dynamic SQL writing module is used to generate dynamic SQL in batches. Specifically, it obtains relevant information about an online table from the database, including the table name, primary key, and fields; selects a pre-configured dynamic SQL script template as needed; and uses FreeMarker's variable substitution capability to replace the variables in the template with the relevant information from the online table, thereby generating dynamic SQL in batches.
[0043] like Figure 3 As shown, the real-time syntax validation and parsing module provides an online editing and configuration interface. This interface supports the writing and formatting of MyBatis' dynamic SQL script syntax and pure SQL syntax. After the user writes the dynamic SQL script through the online editing and configuration interface and clicks parameter settings, the module verifies whether the dynamic SQL script conforms to MyBatis syntax by using a pre-generated SqlSource object. If not, a prompt is displayed; if yes, reflection and regular expressions are used to parse the parameter names and parameter types (parameter types mainly include strings, maps, arrays, numbers, dates, and booleans) of the dynamic SQL script in real time. The module then displays the parameter names, parameter types, and default values on the interface. Constants or variables of the parameter types are set according to the default values, and these variables automatically change based on changes in the business data being processed by the system.
[0044] like Figure 4 As shown, the online script debugging module is used to set parameter test values and transmit these test values, along with the dynamic SQL script, parameter name, parameter type, and data source, to the backend. The backend first verifies whether the parameter test value matches the parameter type. If not, a mismatch message is displayed. If yes, the dynamic SQL script is assembled into a string according to XML format, and the string is verified to conform to XML syntax. If it does not conform, a message is displayed. If it does conform, the parameter is first set to its default value, then a custom test value is set, and the two are combined to generate a map-type input parameter object. The dynamic SQL script generates a MappedStatement required for SQL execution, and then MyBatis is used to execute the dynamic script method using the msId corresponding to the MappedStatement and the map-type parameters. Using the currently transmitted data source, the dynamic script tags are parsed into SQL statements that the database can execute, the SQL statements are executed, and the SQL statements and execution results are returned to the frontend interface for display, thus achieving the effect of online verification of SQL syntax correctness.
[0045] The saving module is used to save the dynamic SQL script to the database after debugging, then immediately refresh the dynamic SQL script content on the current server, preload the MappedStatement, and record the modification time for service invocation. When saving the dynamic SQL script to the database, the saving module also sets the dynamic SQL script as an execution script for different types of databases or as a general type script. After saving, it also stores the version record corresponding to the dynamic SQL script for historical version backtracking and one-click restoration of historical versions.
[0046] like Figure 5 As shown, the calling process module is used to assemble an execution parameter map based on the executed dynamic SQL script, the configured default parameter values, and the real-time transmitted parameter values. Then, it obtains the data source type based on the data source of the current business execution, searches for the dynamic SQL script of that data source type, and executes it. If the search fails, it uses a general type of script to execute, achieving the effect of real-time effect.
[0047] During the execution of the dynamic SQL script, the calling process module first verifies whether the set parameter type and the type of the parameter value transmitted in real time are consistent. If they are inconsistent, a prompt will be issued.
[0048] Since the apparatus described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention.
[0049] Example 3
[0050] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1, as detailed in Embodiment 3. This embodiment provides an electronic device, such as... Figure 7 As shown, it includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it can implement any of the embodiments in Example 1.
[0051] Since the electronic device described in this embodiment is the device used to implement the method in Embodiment 1 of this application, those skilled in the art can understand the specific implementation method and various variations of the electronic device in this embodiment based on the method described in Embodiment 1 of this application. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection of this application.
[0052] Example 4
[0053] Based on the same inventive concept, this application provides a storage medium corresponding to Embodiment 1, as detailed in Embodiment 4. This embodiment provides a computer-readable storage medium, such as... Figure 8 As shown, a computer program is stored thereon, which, when executed by a processor, can implement any of the embodiments in Example 1.
[0054] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for online editing of dynamic SQL, characterized in that: This includes the real-time syntax checking and parsing process, the online debugging process for the debugging script, the saving process, and the calling process; The real-time syntax validation and parsing process includes: providing an online editing and configuration interface that supports writing and formatting MyBatis dynamic SQL script syntax and pure SQL syntax; after the user writes the dynamic SQL script through the online editing and configuration interface and clicks parameter settings, the dynamic SQL script is validated to ensure it conforms to MyBatis syntax by pre-generating a SqlSource object; if not, a prompt is displayed; if yes, reflection and regular expressions are used to parse the parameter names and parameter types of the dynamic SQL script in real time; then, the parameter names, parameter types, and default values are displayed on the interface; and constants or variables of the parameter types are set according to the default values, with the variables automatically changing according to changes in the business data currently being operated by the system. The online script debugging process includes: setting parameter test values, transmitting the parameter test values along with the dynamic SQL script, parameter name, parameter type, and data source to the backend; the backend first verifies whether the parameter test values match the parameter type. If not, a mismatch message is displayed; if yes, the dynamic SQL script is assembled into a string according to XML format, and the string is verified to conform to XML syntax. If it does not conform, a message is displayed; if it does conform, the parameter is first set to the default value, then a custom test value is set, and the two are combined to generate a map-type input parameter object; the dynamic SQL script is used to generate the MappedStatement required for SQL execution, and then the msId corresponding to the MappedStatement and the map-type input parameter object are used to execute the dynamic script method using MyBatis; using the currently transmitted data source, the dynamic script is parsed into an SQL statement that the database can execute, the SQL statement is executed, and the SQL statement and execution result are returned to the front-end interface for display, thereby achieving the effect of online verification of SQL syntax correctness. The saving process includes: after debugging, saving the dynamic SQL script to the database, then immediately refreshing the dynamic SQL script content of the current server, preloading the MappedStatement, and recording the modification time for service calls. The invocation process includes: assembling an execution parameter map based on the executed dynamic SQL script, the configured default parameter values, and the parameter values transmitted in real time; then obtaining the data source type based on the data source of the current business execution; searching for and executing the dynamic SQL script of that data source type; if the search fails, using a general type of script for execution to achieve the effect of real-time effect.
2. The online editing method for dynamic SQL according to claim 1, characterized in that: It also includes the process of writing dynamic SQL, which includes: obtaining relevant information of an online table from the database, including the table name, primary key and fields; selecting a pre-configured dynamic SQL script template as needed; using FreeMarker variable substitution capabilities to replace the variables in the template with the relevant information of the online table; and generating dynamic SQL in batches.
3. The online editing method for dynamic SQL according to claim 1, characterized in that: When saving the dynamic SQL script to the database, the dynamic SQL script is also set as a running script for different types of databases or as a general type of script; after saving, the version record corresponding to the dynamic SQL script is also stored for historical version backtracking and one-click restoration of historical versions.
4. The online editing method for dynamic SQL according to claim 3, characterized in that: During the execution of the dynamic SQL script, the system first checks whether the set parameter type and the type of the parameter value transmitted in real time are consistent. If they are inconsistent, a prompt will be displayed.
5. An online editing device for dynamic SQL, characterized in that: include: Real-time syntax validation and parsing module: This module provides an online editing and configuration interface that supports the writing and formatting of MyBatis' dynamic SQL script syntax and pure SQL syntax. After the user completes the dynamic SQL script through the online editing configuration interface and clicks on parameter settings, the system verifies whether the dynamic SQL script conforms to MyBatis syntax using a pre-generated SqlSource object. If not, a prompt is displayed; if yes, reflection combined with regular expressions is used to parse the parameter names and parameter types of the dynamic SQL script in real time. Then, the parameter names, parameter types, and default values are displayed on the interface. Constants or variables of the parameter types are set according to the default values, and these variables can automatically change according to changes in the business data currently being processed by the system. Online script debugging module: used to set parameter test values and transmit the parameter test values, along with the dynamic SQL script, the parameter name, the parameter type, and the data source, to the backend; The backend first verifies whether the parameter test value matches the parameter type. If not, a mismatch message is displayed. If yes, the dynamic SQL script is assembled into a string according to XML format, and the string is verified to conform to XML syntax. If it does not conform, a message is displayed. If it does conform, the parameter is first set to the default value, then the custom test value is set, and the two are combined to generate a map-type input parameter object. The dynamic SQL script is used to generate the MappedStatement required for SQL execution, and then MyBatis is used to execute the dynamic script method using the msId corresponding to the MappedStatement and the map-type parameters. Using the currently transmitted data source, the dynamic script tags are parsed into SQL statements that the database can execute, the SQL statements are executed, and the SQL statements and execution results are returned to the front-end interface for display, thereby achieving the effect of online verification of the correctness of SQL syntax. The save module is used to save the dynamic SQL script to the database after debugging, then immediately refresh the dynamic SQL script content of the current server, preload the MappedStatement, and record the modification time for service calls. The calling process module is used to assemble an execution parameter map based on the dynamic SQL script being executed, the configured default parameter values, and the parameter values transmitted in real time. Then, it obtains the data source type based on the data source of the current business execution, searches for the dynamic SQL script of that data source type and executes it. If the search fails, it uses a general type of script to execute, achieving the effect of real-time effect.
6. The online editing device for dynamic SQL according to claim 5, characterized in that: Also includes: The dynamic SQL writing module is used to generate dynamic SQL in batches. Specifically, it obtains relevant information about an online table from the database, including the table name, primary key, and fields; selects a pre-configured dynamic SQL script template as needed; and uses FreeMarker's variable substitution capability to replace the variables in the template with the relevant information from the online table, thereby generating dynamic SQL in batches.
7. The online editing device for dynamic SQL according to claim 5, characterized in that: When the saving module saves the dynamic SQL script to the database, it also sets the dynamic SQL script as a running script for different types of databases or as a general type of script. After saving, it also stores the version record corresponding to the dynamic SQL script for historical version backtracking and one-click restoration of historical versions.
8. The online editing device for dynamic SQL according to claim 5, characterized in that: During the execution of the dynamic SQL script, the calling process module first verifies whether the set parameter type and the type of the parameter value transmitted in real time are consistent. If they are inconsistent, a prompt will be issued.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 4.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method for realizing configurable dynamic SQL (Structured Query Language) based on Mybatis
CN116561157A
Method for online integrating SQL (Structured Query Language) based on low-code platform
CN118860361A