Data query method and related equipment

By intercepting the paging parameters in the query instructions in the database system and using the paging plug-in to process the query instructions, the problem of frequent modification of the paging query code in the existing technology is solved, and an efficient and pluggable paging query function is realized.

CN112015751BActive Publication Date: 2025-05-23BOE TECHNOLOGY GROUP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010891884.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-28
Publication Date
2025-05-23
Estimated Expiration
2041-05-23

AI Technical Summary

Technical Problem

When implementing paging query in a database system, the code needs to be modified to adapt to different database systems. When the data volume is large, the paging query logic is complex and it is difficult to meet business needs.

Method used

The paging query function is realized by intercepting paging parameters in the query instructions and using the paging plug-in to process the query instructions. This method does not require modifying the original code, supports use in different database systems, and is logically concise.

Benefits of technology

It realizes the pluggability of the paging query function, improves the efficiency of paging query in data query, simplifies code maintenance, and is suitable for different database systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112015751B_ABST
    Figure CN112015751B_ABST
Patent Text Reader

Abstract

The disclosed embodiment provides a data query method and related equipment, including: obtaining a query instruction; intercepting the query instruction with a paging plug-in and determining whether there is a paging parameter in the query instruction; if there is a paging parameter in the query instruction, according to the paging parameter, using the paging plug-in to process the query instruction to obtain a paging query instruction; executing the paging query instruction and obtaining a paging query result. The data query method and related equipment provided by the disclosed embodiment can solve the problem that the existing paging operation is inconvenient to implement to a certain extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of data processing technology, and in particular, to a data query method and related equipment. Background Art

[0002] For queries with large amounts of data, if all the data is queried at once, it will not only reduce system performance but may also cause the system to crash. This is how the paging query function comes into being. Only a small part of the data is queried at a time. This can not only improve system efficiency but also improve data utilization.

[0003] A paging query method in the prior art is to embed paging-related codes where paging queries are needed. However, when the database used by the system is changed, the paging code must be modified, which is relatively cumbersome to handle. Summary of the invention

[0004] In view of this, the embodiments of the present disclosure propose a data query method and related devices to solve the above problems to a certain extent.

[0005] A first aspect of the embodiments of the present disclosure provides a data query method, including:

[0006] Get query instructions;

[0007] Using a paging plug-in to intercept the query instruction and determine whether there is a paging parameter in the query instruction;

[0008] If there is a paging parameter in the query instruction, the paging plug-in is used to process the query instruction according to the paging parameter to obtain a paging query instruction;

[0009] Execute the paging query instruction and obtain the paging query result.

[0010] Optionally, the query instruction is an SQL instruction based on a MyBatis database, and the method further includes:

[0011] The paging plug-in is set by utilizing the SQL interception interface reserved by the MyBatis-based database.

[0012] Optionally, the determining whether there is a paging parameter in the query instruction includes:

[0013] Obtaining SQL input parameters in the query instruction;

[0014] The SQL input parameters are traversed to determine whether the SQL input parameters contain the paging parameters.

[0015] Optionally, the paging parameters include parameters that inherit a specified paging class;

[0016] The method of obtaining a paging query instruction by processing the query instruction using the paging plug-in according to the paging parameters includes: obtaining a paging query instruction by processing the query instruction using the paging plug-in according to the parameters of the inherited specified paging class.

[0017] Optionally, if the SQL input parameter is a HashMap, the paging parameter is a specified value; if the SQL input parameter is a POJO object, the paging parameter is a specific attribute of the POJO object.

[0018] Optionally, the method further comprises:

[0019] Determine whether there is a total number of queries parameter in the query instruction by using the paging plug-in;

[0020] If there is a total query number parameter in the query instruction, the paging plug-in is used to obtain the total query number, and the total query number is added to the paging parameter.

[0021] Optionally, executing the paging query instruction and obtaining the paging query result includes:

[0022] If the page number specified in the paging parameter is greater than the page number of the last page in the query result, the data of the last page is returned as the paging query result.

[0023] A second aspect of the embodiments of the present disclosure provides a data query device, including:

[0024] The acquisition module is configured to: acquire a query instruction;

[0025] The interception module is configured to: intercept the query instruction using a paging plug-in and determine whether there is a paging parameter in the query instruction; and if there is a paging parameter in the query instruction, use the paging plug-in to process the query instruction according to the paging parameter to obtain a paging query instruction;

[0026] The processing module is configured to: execute the paging query instruction and obtain the paging query result.

[0027] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any method described in the first aspect is implemented.

[0028] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium is provided, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute any method described in the first aspect.

[0029] From the above description, it can be seen that the data query method and related equipment provided by one or more embodiments of the present disclosure use a paging plug-in to intercept query instructions and determine whether the query instructions have paging parameters, and when the query instructions have paging parameters, the query instructions are processed according to the paging parameters to obtain paging query instructions and paging query results are obtained accordingly, so that the paging function can be implemented by using the paging plug-in only by adding paging parameters to the query instructions without changing the original code, thereby realizing the pluggability of the paging query function and improving the efficiency of implementing the paging query function in data query. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate one or more embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only one or more embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0031] Figure 1 A flowchart of an embodiment of a data query method provided by an embodiment of the present disclosure;

[0032] Figure 2 A flowchart of another embodiment of the data query method provided by the embodiment of the present disclosure;

[0033] Figure 3 A schematic diagram of the structure of an embodiment of a data query device provided by an embodiment of the present disclosure;

[0034] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0035] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0036] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in one or more embodiments of the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in one or more embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect.

[0037] The present disclosure provides a data query method, which includes the following steps:

[0038] Get query instructions;

[0039] Using a paging plug-in to intercept the query instruction and determine whether there is a paging parameter in the query instruction;

[0040] If there is a paging parameter in the query instruction, the paging plug-in is used to process the query instruction according to the paging parameter to obtain a paging query instruction;

[0041] Execute the paging query instruction and obtain the paging query result.

[0042] It can be seen from the above embodiments that the data query method provided by the embodiments of the present disclosure utilizes a paging plug-in to intercept query instructions and determine whether the query instructions have paging parameters, and when the query instructions have paging parameters, the query instructions are processed according to the paging parameters to obtain paging query instructions and paging query results are obtained accordingly, so that the paging function can be implemented by utilizing the paging plug-in only by adding paging parameters to the query instructions without changing the original code, thereby realizing the pluggability of the paging query function and improving the efficiency of implementing the paging query function in data query.

[0043] In some cases, for the backend service system that uses Java and MyBatis for database operations, it is inevitable to frequently query the database. If all the data in the database is queried at once every time, the system performance will inevitably be greatly reduced. Especially for queries with a large amount of data, querying all the data at once will not only reduce system performance but also cause the system to crash (for example, the attendance data in the intelligent body temperature system usually has a large amount of data, and generally requires the use of data paging). In this way, the paging query function is needed to query only part of the data at a time, which can not only improve system efficiency but also improve data utilization.

[0044] In the face of the problem of paging query, one implementation method is to pre-add paging parameters in the Structured Query Language (SQL) statement. This is a very tedious task. Once there is a need for paging query, the paging-related code needs to be embedded. Moreover, when the system changes the database used, the paging code must be modified in such a situation, which is also a headache. Another implementation method is to use paging plug-ins, but these paging plug-ins generally need to reassemble a separate paging parameter. Some paging plug-ins require the method name to be named according to the specified ending, and the data type returned after using the paging parameter specified by the paging plug-in must also be returned according to the type specified by the paging plug-in. The original method needs to be modified before it can be used, and certain business codes need to be modified to transform the original function. Although these methods can achieve the ultimate goal, these methods have certain limitations, such as only maintaining the paging properties of the method. However, sometimes, for data queries with not large data volumes, both a paging method and a non-paged query are required, and these cannot meet this demand. In this way, you must write two methods with the same logical processing (one for paging queries and one for non-paged queries). When the business needs change, you need to modify two codes to keep the functions complete, which will lead to low work efficiency.

[0045] Figure 1 A flow chart of an embodiment of a data query method provided by an embodiment of the present disclosure is shown.

[0046] like Figure 1 As shown, the data query method includes:

[0047] Step 102: Get the query instruction.

[0048] Optionally, the data query method is designed for a backend service system that uses Java Development Kit (JDK) 1.8 and above and uses MyBatis to perform paging query operations on a database. Wherein, the query instruction is an SQL instruction based on the MyBatis database.

[0049] MyBatis is a persistence framework that supports customized SQL, stored procedures, and advanced mapping. MyBatis can use simple XML or annotations to configure and map native information, mapping interfaces and Java POJOs (Plain Ordinary Java Objects) into records in the database.

[0050] Step 104: intercept the query instruction using a paging plug-in and determine whether there is a paging parameter in the query instruction.

[0051] In this step, the paging plug-in can be set by using the SQL interception interface reserved by the MyBatis-based database.

[0052] MyBatis has a reserved SQL execution interception point interface. Therefore, the paging plug-in can intercept the query method of the SQL executor (Executor), obtain the SQL input parameters at the interception point, and then traverse the SQL input parameters to determine whether there are paging parameters.

[0053] Optionally, the paging plug-in is lightweight, pluggable, easy to use, etc. Optionally, the paging plug-in is a JAR package, which is introduced to initialize the interceptor object when performing data query, and the paging plug-in does not change the return value, so the paging plug-in can be used non-invasively.

[0054] As an optional embodiment, the determining whether there is a paging parameter in the query instruction includes:

[0055] Obtaining SQL input parameters in the query instruction;

[0056] The SQL input parameters are traversed to determine whether the SQL input parameters contain the paging parameters.

[0057] In this embodiment, the paging parameters refer to parameters for how to paginate the paging query results, for example, how many query data are included in each page (page size), which page to start displaying (current page number), the total number of pages, etc. If the purpose of the query includes paging query, the query instruction will include corresponding paging parameters, and whether there are paging parameters can be determined by traversing the SQL input parameters in the query instruction.

[0058] Step 106: If there are paging parameters in the query instruction, the paging plug-in is used to process the query instruction according to the paging parameters to obtain a paging query instruction.

[0059] In this step, if there are paging parameters in the query instruction, the paging plug-in processes the query instruction (SQL instruction) to obtain a paging query instruction (paging SQL instruction), and returns the paging query instruction to the intercepted SQL executor to execute the paging query instruction, thereby completing the paging query.

[0060] Optionally, if there is no paging parameter in the query instruction, the original query instruction (SQL instruction) is returned to the executor for execution.

[0061] In one or more embodiments of the present disclosure, the data query method may further include the following steps:

[0062] Determine whether there is a total number of queries parameter in the query instruction by using the paging plug-in;

[0063] If there is a total query parameter in the query instruction, the total query is obtained by using the paging plug-in, and the total query is added to the paging parameter. When the paging plug-in is used to process the query instruction according to the paging parameter to obtain a paging query instruction, the corresponding information of the total query can be added to the paging query instruction.

[0064] Generally, when performing paging queries, it is necessary to query the total number (i.e., the total number of data obtained based on the query instruction). However, if, for example, only the first page of data needs to be queried, there is no need to query the total number. Optionally, when the amount of data is relatively large, a query total number parameter is added to the query instruction to indicate whether to query the total number. If only the top 20 data is needed, this approach is more useful, as it avoids performance waste caused by querying the total number and reduces service response time.

[0065] In this way, the total number of queries is returned only when it is needed, thereby improving work efficiency.

[0066] As an optional embodiment, the paging parameters include parameters that inherit the specified paging class;

[0067] The step of obtaining a paging query instruction by processing the query instruction using the paging plug-in according to the paging parameter includes: obtaining a paging query instruction by processing the query instruction using the paging plug-in according to the parameter of the inherited specified paging class.

[0068] In this embodiment, according to the paging parameters, the paging plug-in can process the query instruction in the paging query instruction according to the parameters of the inherited specified paging class in the paging parameters to obtain the paging query instruction. In this way, when executing the paging query instruction, the paging function can be realized by inheriting the specified paging class corresponding to the paging parameter, that is, the paging function can be added by inheriting the specified paging class without affecting the original code. In addition, when the paging operation is not needed, the paging operation can be turned off by modifying the paging parameters, which is very convenient to use.

[0069] In the existing paging plug-ins, the paging parameters in the paging plug-in are directly used and must be independent query parameters. Some other existing paging plug-ins require a separate parameter or even a fixed alias, or need to return a specified quantity type, which will lead to low work efficiency. In this embodiment, the paging plug-in can obtain the paging parameter object by inheritance (that is, the custom query parameter class inherits the paging function parent class in the plug-in). In this embodiment, the paging parameter does not have a fixed restriction in the existing paging plug-in. As long as the specified paging parameter is included, the paging function can be realized. The recommended way to obtain this paging parameter is to obtain it by inheriting the specified class, so that the modification of the original code can be minimized to obtain the paging function.

[0070] In some cases, other methods are also supported to set paging parameters. As long as the paging parameters are included, the paging plug-in can intelligently judge and perform paging processing.

[0071] Optionally, when using Java or MyBatis to perform database operations and need to perform paging queries on database data, the query parameters in the query instruction only need to include paging parameters of a specified type to implement the paging function. The paging parameters are obtained through inheritance. As long as the query parameters inherit the specified class, the query method has the paging function, and other processing logic does not require any modification.

[0072] In some optional embodiments, not only the inheritance method is supported to obtain the paging query function, but the paging query function can be obtained as long as the paging parameters are included.

[0073] Optionally, if the SQL input parameter is a HashMap, the paging parameter is a specified value; if the SQL input parameter is a POJO object, the paging parameter is a specific attribute of the POJO object.

[0074] In this embodiment, when passing paging parameters, intelligent filtering is performed for different SQL input parameters. When the input parameter is a HashMap, paging query can be performed as long as a certain value is a paging parameter. When the input parameter is a POJO object, paging query can be performed as long as a certain attribute is a paging parameter. In addition, optionally, paging query can also be performed when a certain input parameter is a separate paging parameter. Generally, the POJO object class is selected to inherit the basic paging class in this embodiment, but which method can be selected for transformation according to the design of the current interface, thereby minimizing the amount of modification of the current code.

[0075] Step 108: Execute the paging query instruction and obtain the paging query result.

[0076] As an optional embodiment, executing the paging query instruction and obtaining the paging query result includes:

[0077] If the page number specified in the paging parameter is greater than the page number of the last page in the query result, the data of the last page is returned as the paging query result.

[0078] In a scenario where multiple people are operating, it is easy for others to delete part of the data during the query, causing the page number being queried to exceed the maximum page number. If the page number passed in is used, no data will be found, which is not the expected result. In this embodiment, when the specified page number is greater than the last page during the paging query, the last page of data is queried. After this processing, the data will not be found due to an error in the page number. The data will not be found only when there is no data, thus avoiding the situation where the non-empty data query is empty.

[0079] Optionally, if the query logic is the same, you can use parameters to set whether the query is paginated, and switch between pagination and non-pagination without changing the code.

[0080] It can be seen from the above embodiments that the data query method provided by the embodiments of the present disclosure utilizes a paging plug-in to intercept query instructions and determine whether the query instructions have paging parameters, and when the query instructions have paging parameters, the query instructions are processed according to the paging parameters to obtain paging query instructions and paging query results are obtained accordingly, so that the paging function can be implemented by utilizing the paging plug-in only by adding paging parameters to the query instructions without changing the original code, thereby realizing the pluggability of the paging query function and improving the efficiency of implementing the paging query function in data query.

[0081] In addition, by inheriting the basic paging class through the paging plug-in, the ordinary query method is changed to the paging method, and no other processing logic needs to be modified; in addition, when encountering a request that does not require the paging function, the paging function of this query can be turned off by turning off the paging function in the parameters. This can not only achieve multiple uses of one method but also avoid the modification of redundant code. This will improve the focus of the code business logic, and there is no need to modify the original code to add the paging function, thereby improving work efficiency. The data query method provided by the embodiment of the present disclosure obtains the paging query function by inheriting the specified class. The back-end interface does not need to reserve independent paging parameters to realize the paging query function, and the pluggable nature of the paging function is completely realized. It can not only achieve the fastest function modification of the existing query method, but also control whether the paging function is used.

[0082] Figure 2 A flow chart of another embodiment of the data query method provided by the embodiment of the present disclosure is shown.

[0083] like Figure 2As shown, the data query method includes the following steps:

[0084] Introduce the paging plugin package and initialize the paging plugin (Executor Query Interceptor) interception object; optionally, when initializing the paging plugin object, you can set the database dialect according to the database used, such as using the MySQL database dialect (currently supports paging operations of MySQL, DB2, Oracle and other databases);

[0085] Adding paging parameter objects in the query method can realize the paging function; paging parameters can be added according to the specific design;

[0086] Get the total number of query results from the paging parameter object; the paging plug-in will put the total number of queries into the paging parameter object, and finally get the total number from the paging parameter object as part of the return value for processing and return.

[0087] It should be noted that the method of one or more embodiments of the present disclosure may be performed by a single device, such as a computer or server. The method of this embodiment may also be applied in a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices may only perform one or more steps in the method of one or more embodiments of the present disclosure, and the multiple devices may interact with each other to complete the described method.

[0088] Figure 3 A structural schematic diagram of an embodiment of a data query device provided by an embodiment of the present disclosure is shown.

[0089] like Figure 3 As shown, the data query device includes:

[0090] The acquisition module 201 is configured to: acquire a query instruction;

[0091] The interception module 202 is configured to: intercept the query instruction using a paging plug-in and determine whether there is a paging parameter in the query instruction; and if there is a paging parameter in the query instruction, use the paging plug-in to process the query instruction according to the paging parameter to obtain a paging query instruction;

[0092] The processing module 203 is configured to: execute the paging query instruction and obtain the paging query result.

[0093] It can be seen from the above embodiments that the data query device provided by the embodiments of the present disclosure uses a paging plug-in to intercept query instructions and determine whether the query instructions have paging parameters, and when the query instructions have paging parameters, the query instructions are processed according to the paging parameters to obtain paging query instructions and paging query results are obtained accordingly, so that the paging function can be implemented by using the paging plug-in only by adding paging parameters to the query instructions without changing the original code, thereby realizing the pluggability of the paging query function and improving the efficiency of implementing the paging query function in data query.

[0094] Optionally, the query instruction is an SQL instruction of a MyBatis-based database, and the interception module 202 is configured to set the paging plug-in by using a SQL interception interface reserved by the MyBatis-based database.

[0095] Optionally, the interception module 202 is configured to:

[0096] Obtaining SQL input parameters in the query instruction;

[0097] The SQL input parameters are traversed to determine whether the SQL input parameters contain the paging parameters.

[0098] Optionally, the paging parameters include parameters that inherit a specified paging class;

[0099] The interception module 202 is configured to: obtain a paging query instruction by using the paging plug-in according to the query instruction according to the inherited parameter of the specified paging class.

[0100] Optionally, if the SQL input parameter is a HashMap, the paging parameter is a specified value; if the SQL input parameter is a POJO object, the paging parameter is a specific attribute of the POJO object.

[0101] Optionally, the interception module 202 is configured to:

[0102] Determine whether there is a total number of queries parameter in the query instruction by using the paging plug-in;

[0103] If there is a total query number parameter in the query instruction, the paging plug-in is used to obtain the total query number, and the total query number is added to the paging parameter.

[0104] Optionally, the processing module 203 is configured to:

[0105] If the page number specified in the paging parameter is greater than the page number of the last page in the query result, the data of the last page is returned as the paging query result.

[0106] For the convenience of description, the above devices are described in terms of functions divided into various modules. Of course, when implementing one or more embodiments of the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0107] The apparatus of the above-mentioned embodiment is used to implement the corresponding method in the above-mentioned embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0108] Figure 4 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 301, a memory 302, an input / output interface 303, a communication interface 304, and a bus 305. The processor 301, the memory 302, the input / output interface 303, and the communication interface 304 are connected to each other in communication within the device through the bus 305.

[0109] The processor 301 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present disclosure.

[0110] The memory 302 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 302 can store an operating system and other application programs. When the technical solution provided by the embodiment of the present disclosure is implemented by software or firmware, the relevant program code is stored in the memory 302 and called and executed by the processor 301.

[0111] The input / output interface 303 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.

[0112] The communication interface 304 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0113] The bus 305 comprises a pathway for transmitting information between the various components of the device (eg, the processor 301 , the memory 302 , the input / output interface 303 , and the communication interface 304 ).

[0114] It should be noted that, although the above device only shows the processor 301, the memory 302, the input / output interface 303, the communication interface 304 and the bus 305, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present disclosure, and does not necessarily include all the components shown in the figure.

[0115] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0116] The above describes specific embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0117] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples. Based on the concept of the present disclosure, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present disclosure as described above, which are not provided in detail for the sake of simplicity.

[0118] In addition, to simplify the description and discussion, and in order not to make one or more embodiments of the present disclosure difficult to understand, known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided figures. In addition, the device can be shown in the form of a block diagram to avoid making one or more embodiments of the present disclosure difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which one or more embodiments of the present disclosure will be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present disclosure, it is apparent to those skilled in the art that one or more embodiments of the present disclosure can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0119] Although the present disclosure has been described in conjunction with specific embodiments of the present disclosure, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.

[0120] One or more embodiments of the present disclosure are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present disclosure should be included in the protection scope of the present disclosure.

Claims

1. A data query method, include: Obtain a query instruction, wherein the query instruction is an SQL instruction based on a MyBatis database; Using a paging plug-in to intercept the query instruction and determine whether there is a paging parameter in the query instruction, the paging plug-in is set by using a SQL interception interface reserved by a MyBatis-based database; If there is a paging parameter in the query instruction, the paging plug-in is used to process the query instruction according to the paging parameter to obtain a paging query instruction; Execute the paging query instruction and obtain the paging query result; Wherein, the method further comprises: Determine whether there is a total number of queries parameter in the query instruction by using the paging plug-in; If there is a total query number parameter in the query instruction, the total query number is obtained by using the paging plug-in, and the total query number is added to the paging parameter; Wherein, the paging parameters include parameters that inherit the specified paging class, and the paging query instruction is obtained by using the paging plug-in according to the query instruction according to the paging parameters, including: According to the inherited parameters of the specified paging class, the paging plug-in is used to process the query instruction to obtain the paging query instruction; Wherein, if there is a paging parameter in the query instruction, according to the paging parameter, the paging plug-in is used to process the query instruction to obtain a paging query instruction, including: If there is a paging parameter in the query instruction, the paging plug-in processes the query instruction to obtain the paging query instruction; If there is no paging parameter in the query instruction, the query instruction is returned to the executor for execution.

2. The method according to claim 1, in, The query instruction is an SQL instruction of a MyBatis-based database, and the method further comprises: The paging plug-in is set by utilizing the SQL interception interface reserved by the MyBatis-based database.

3. The method according to claim 2, in, The determining whether there is a paging parameter in the query instruction includes: Obtaining SQL input parameters in the query instruction; The SQL input parameters are traversed to determine whether the SQL input parameters contain the paging parameters.

4. The method according to claim 3, in, If the SQL input parameter is a HashMap, the paging parameter is a specified value; if the SQL input parameter is a POJO object, the paging parameter is a specific attribute of the POJO object.

5. The method according to claim 1, in, The executing the paging query instruction and obtaining the paging query result includes: If the page number specified in the paging parameter is greater than the page number of the last page in the query result, the data of the last page is returned as the paging query result.

6. A data query device, include: The acquisition module is configured to: acquire a query instruction, wherein the query instruction is an SQL instruction of a MyBatis-based database; The interception module is configured to: intercept the query instruction using a paging plug-in and determine whether there is a paging parameter in the query instruction, wherein the paging plug-in is set using a SQL interception interface reserved by a MyBatis-based database; and, if there is a paging parameter in the query instruction, obtain a paging query instruction by processing the query instruction using the paging plug-in according to the paging parameter; The processing module is configured to: execute the paging query instruction and obtain the paging query result; The interception module is configured to use the paging plug-in to determine whether there is a total query parameter in the query instruction; if there is a total query parameter in the query instruction, use the paging plug-in to obtain the total query, and add the total query to the paging parameter; Wherein, the paging parameters include parameters inherited from a specified paging class, and the interception module is further configured to obtain the paging query instruction by using the paging plug-in according to the parameters inherited from the specified paging class and processing the query instruction; Wherein, the interception module is configured such that if there is a paging parameter in the query instruction, the paging plug-in processes the query instruction to obtain the paging query instruction; if there is no paging parameter in the query instruction, the query instruction is returned to the executor for execution.

7. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 5 when executing the program.

8. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Paging query method and device for database

    CN111125148A