A mapping relationship searching method and device, electronic equipment and storage medium
By parsing Java files to establish mapping relationships, the problem of difficulty in determining the impact of data access layer code modifications on database tables is solved, achieving more accurate monitoring and evaluation.
Patent Information
- Application Number
- CN202310657539.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2043-06-05
AI Technical Summary
During the development of fintech software, after modifying the data access layer code, it is impossible to determine its impact on the underlying database tables, which increases the difficulty of troubleshooting and testing.
By parsing the Java files in the project source code, establishing the mapping relationship between the data access layer and the database operation layer, extracting the database table names, forming a mapping list, and tracing the impact of modifications to the data access layer.
Accurately determine the impact of data access layer code modifications on database tables, and improve monitoring and evaluation capabilities during testing.
Smart Images

Figure CN116680311B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a mapping relationship search method, device, electronic device and storage medium. Background Art
[0002] With the popularization of finance in daily life, financial companies are paying more and more attention to database security issues. For example, the security of bank databases is related to the property safety of all customers in the entire banking system. Therefore, the data security requirements for financial technology software are also getting higher and higher.
[0003] During the software development process, with the upgrade of data security requirements and system architecture, the underlying database will be required to be upgraded. Database replacement is inevitable in the software development process. For historical data, database replacement can be performed through data migration. However, different underlying databases have different operating logic for the program in the data access layer, and the corresponding code needs to be modified to adapt. However, in the process of modifying the program's data access layer code, when modifying a data access layer code, one or more tables in the database may be affected. This approach will have the following problems:
[0004] 1. Due to the modification of the data access layer code, it is not certain which underlying database tables are affected. It is difficult to troubleshoot after the problem occurs.
[0005] 2. Due to the modification of the data access layer code, it is not certain which underlying database tables are affected. It is also difficult to monitor and verify the affected tables during the testing process.
[0006] Therefore, there is an urgent need for a method that can easily find the relationship between the data access layer and the database table. Summary of the Invention
[0007] The purpose of the present invention is to overcome the above-mentioned technical deficiencies and provide a mapping relationship search method, device, electronic device and storage medium suitable for financial technology or other related technical fields, so as to solve the technical problem in the prior art that the database table affected by the data access layer cannot be determined.
[0008] In order to achieve the above technical objectives, the present invention adopts the following technical solutions:
[0009] In a first aspect, the present invention provides a mapping relationship search method, comprising the following steps:
[0010] Obtain the project source code, find the Java file from the project source code, and add the Java file to the Java file list;
[0011] Traversing the Java file list, finding the data access layer class name in the Java file list, and obtaining all data access layer names under the data access layer class, and then establishing a data access layer list, wherein the data access layer list reflects the mapping relationship between the data access layer class name and the data access layer name;
[0012] Traversing the Java file list, finding the database operation layer class name in the Java file list, and obtaining all database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establishing a database operation list, wherein the database operation list reflects the mapping relationship between the data access layer name, the database operation layer class name and the database table name;
[0013] A mapping list is established based on the data access layer list and the database operation list, wherein the mapping list reflects the mapping relationship between the data access layer class name, the data access layer name and the database table name.
[0014] In some embodiments, traversing the Java file list, finding the data access layer class name in the Java file list, and obtaining all data access layer names under the data access layer class, and then establishing a data access layer list includes:
[0015] Traversing the Java file list, converting the file names to lowercase, and finding the data access layer class file to obtain the data access layer class name;
[0016] The data access layer class file is parsed into an abstract syntax tree, all data access layers under the current data access layer class are obtained through a first regular expression, and after extracting the names of the data access layers, a data access layer list is established.
[0017] In some embodiments, traversing the Java file list, finding the database operation layer class name in the Java file list, and obtaining all database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establishing a database operation list includes:
[0018] Traversing the Java file list, converting the file names to lowercase, and finding the database operation layer class file to obtain the database operation layer class name;
[0019] The database operation layer class file is parsed into an abstract syntax tree, and after obtaining all database table names under the current data access layer class and the data access layer used in the database operation layer class through the second regular expression and the third regular expression respectively, a database operation list is established.
[0020] In some embodiments, the data access layer class file is a file ending with dto.
[0021] In some embodiments, the database operation layer class file is a file ending with mapper.
[0022] In some embodiments, establishing a mapping list based on the data access layer list and the database operation list includes:
[0023] Traverse the data access layer list, judge each data access layer in the data access layer list in turn, and determine whether the current data access layer is included in the database operation list. If so, add the data access layer class name, data access layer name and corresponding database table name to the mapping list.
[0024] In some embodiments, the method further comprises:
[0025] When it is determined that the database operation list does not include the current data access layer, the next data access layer is determined.
[0026] In a second aspect, the present invention further provides a mapping relationship search device, comprising:
[0027] A source code acquisition module is used to obtain the project source code, find the Java file from the project source code, and add the Java file to the Java file list;
[0028] a data access layer list establishment module, configured to traverse the Java file list, find the data access layer class name in the Java file list, obtain all data access layer names under the data access layer class, and then establish a data access layer list, wherein the data access layer list reflects the mapping relationship between the data access layer class name and the data access layer name;
[0029] a database operation list establishment module, configured to traverse the Java file list, find the database operation layer class name in the Java file list, obtain all database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establish a database operation list, wherein the database operation list reflects the mapping relationship between the data access layer name, the database operation layer class name and the database table name;
[0030] The mapping list establishing module is used to establish a mapping list based on the data access layer list and the database operation list, wherein the mapping list reflects the mapping relationship between the data access layer class name, the data access layer name and the database table name.
[0031] In a third aspect, the present invention further provides an electronic device, comprising: a processor and a memory;
[0032] The memory stores a computer program executable by the processor;
[0033] When the processor executes the computer program, the steps in the mapping relationship search method described above are implemented.
[0034] In a fourth aspect, the present invention further provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the mapping relationship search method as described above.
[0035] Compared with the prior art, the mapping relationship search method, device, electronic device and storage medium provided by the present invention first obtain the project source code, find the Java file from the project source code, and add the Java file to the Java file list; then traverse the Java file list, find the data access layer class name in the Java file list, and obtain all the data access layer names under the data access layer class, and then establish a data access layer list; then traverse the Java file list, find the database operation layer class name in the Java file list, and obtain all the database table names under the database operation layer class and the data access layers used in the database operation layer class, and then establish a database operation list; finally, based on the data access layer list and the database operation list, a mapping list is established. After modifying the program data access layer code, by tracing the database access interface file or database interface access configuration file under the data access layer, parsing the annotated SQL data in the interface file or the SQL statement in the database access configuration file, extracting the database table name therein, the database-related tables that may be affected by the program data access layer modification are obtained, thereby determining the scope of the modification impact, and more accurately monitoring and evaluating the changes and impacts of the relevant databases during the testing process. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 is a flowchart of a mapping relationship search method provided by an embodiment of the present invention;
[0037] Figure 2 This is a flowchart of step S200 in the mapping relationship search method provided by an embodiment of the present invention;
[0038] Figure 3 This is a flowchart of step S300 in the mapping relationship search method provided by an embodiment of the present invention;
[0039] Figure 4Schematic diagram of the functional modules of the mapping relationship search device provided by an embodiment of the present invention;
[0040] Figure 5 It is a schematic diagram of the hardware structure of the electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0042] With the increasing prevalence of finance in daily life, financial companies are increasingly concerned about database security. For example, the security of a bank's database is crucial to the financial security of all customers within the entire banking system. Consequently, data security requirements for fintech software are becoming increasingly stringent. Currently, in the development of fintech software, different underlying databases often have different operational logic within the program's data access layer, requiring code modifications to adapt. However, during these code modifications, it's difficult to determine which underlying database tables are affected by these changes.
[0043] See also Figure 1 , Figure 1 An embodiment of the present invention provides a flowchart of a mapping relationship search method. The mapping relationship search method involved in the present invention can be used in the mapping relationship search application between the data access layer and the database table in the field of financial technology to achieve the purpose of modification tracing. The mapping relationship search method involved in the present invention can be executed by an electronic device that can perform operations such as receiving or sending data, and can be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, portable computers, desktop servers, etc. Figure 1 As shown, the method specifically includes the following steps S100 to S400.
[0044] S100: Obtain project source code, search for a Java file from the project source code, and add the Java file to a Java file list.
[0045] In this embodiment, the project source code is stored in the project management platform gitlab. First, the project source code is obtained from the project management platform through the gitclone command, and then the file suffix ".java" in the project source code is traversed and searched, and added to the java file list.
[0046] S200. Traverse the Java file list, find the data access layer class name in the Java file list, obtain all data access layer names under the data access layer class, and then establish a data access layer list, wherein the data access layer list reflects the mapping relationship between the data access layer class name and the data access layer name.
[0047] In this embodiment, a mapping table between the data access layer and the data access layer class is first established. After searching the data access layer class name in the Java file list, all data access layers under the data access layer class are obtained, and then the names of the data access layers are extracted one by one and saved in the data access layer list in the form of {data access layer name, data access layer class name} objects.
[0048] S300. Traverse the Java file list, find the database operation layer class name in the Java file list, obtain all database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establish a database operation list, wherein the database operation list reflects the mapping relationship between the data access layer name, the database operation layer class name and the database table name.
[0049] In this embodiment, a mapping table is established between the data access layer name, the database operation layer class name and the database table name. The mapping table reflects the relationship between the database table and all data access layers. Therefore, in combination with the data access layer table, the mapping relationship between the data access layer and the database table can be accurately obtained, thereby achieving the purpose of quickly finding the mapping relationship.
[0050] S400: Establish a mapping list based on the data access layer list and the database operation list, wherein the mapping list reflects the mapping relationship between the data access layer class name, the data access layer name and the database table name.
[0051] In this embodiment, by establishing a mapping list, after modifying the program data access layer code, by tracing the database access interface mapper file under the data access layer, or the database interface access configuration XML file, parsing the annotated SQL data in the interface mapper file or the SQL statement in the database access configuration XML file, and extracting the database table name therein, the database table that may be affected by the modification of the program data access layer is obtained.
[0052] In an embodiment of the present invention, the project source code is first obtained, a Java file is found from the project source code, and the Java file is added to a Java file list; the Java file list is then traversed to find the data access layer class name in the Java file list, and all data access layer names under the data access layer class are obtained to establish a data access layer list; the Java file list is then traversed to find the database operation layer class name in the Java file list, and all database table names under the database operation layer class and the data access layers used in the database operation layer class are obtained to establish a database operation list; and finally, a mapping list is established based on the data access layer list and the database operation list. After modifying the program data access layer code, the database access interface file or database interface access configuration file under the data access layer is traced, the annotated SQL data in the interface file or the SQL statement in the database access configuration file is parsed, and the database table names therein are extracted, thereby obtaining the database-related tables that may be affected by the program data access layer modification, thereby determining the scope of the modification impact, and more accurately monitoring and evaluating the changes and impacts of the related databases during the testing process.
[0053] In some embodiments, see Figure 2 , the step S200 specifically includes:
[0054] S210, traversing the Java file list, converting the file names to lowercase, and searching for the data access layer class file to obtain the data access layer class name;
[0055] S220: Parse the data access layer class file into an abstract syntax tree, obtain all data access layers under the current data access layer class using a first regular expression, extract the names of the data access layers, and then create a data access layer list.
[0056] In this embodiment, the Java file list is first traversed, and the file names are uniformly converted to lowercase using the lower() function. The file whose name ends with dto is searched, and the file is the data access layer class name. The file is parsed into an abstract syntax tree according to the Java syntax, and all data access layers under the current class are obtained through the regular expression / / MethodDeclarator[*]. The data access layer names are extracted one by one through the @image attribute and saved in the data access layer list as {data access layer name, data access layer class name} objects.
[0057] In some embodiments, see Figure 3 , the step S300 specifically includes:
[0058] S310, traverse the Java file list, convert the file names to lowercase, find the database operation layer class file, and obtain the database operation layer class name;
[0059] S320: Parse the database operation layer class file into an abstract syntax tree, obtain all database table names under the current data access layer class and the data access layer used in the database operation layer class through the second regular expression and the third regular expression respectively, and then establish a database operation list.
[0060] In this embodiment, a Java file list is traversed, and the file names are uniformly converted to lowercase using the lower() function. A file whose file name ends with "mapper" is searched for. In this case, the file is the name of a database operation layer class. The file is parsed into an abstract syntax tree according to Java syntax. The methods containing the select / insert / update annotations under the current class are obtained using the regular expression / / [Anotation[name="select / insert / update"] / Membervalue / literal[*]] [the inclusion of these three annotations indicates that operations are performed on database tables]. The database table name operated on by the current method is obtained using literal. Then, the data access layer method used in the database operation class is obtained using / / [Anotation[name="select / insert / update"] / Membervalue / ClassOrInterfaceType[*]], and then added to the database operation list in the form of an object {database table name, data access layer name, database operation layer class name}.
[0061] In some embodiments, step S400 specifically includes:
[0062] Traverse the data access layer list, judge each data access layer in the data access layer list in turn, and determine whether the current data access layer is included in the database operation list. If so, add the data access layer class name, data access layer name and corresponding database table name to the mapping list.
[0063] In this embodiment, the data access layer list is traversed, and according to the data access layer, it is determined whether the current data access layer is included in the database operation list. If it is included, it means that the data access layer affects the database table, and is added to the mapping list in the object form of {data access layer, class name where the data access layer is located, database table name}.
[0064] In some embodiments, step S400 further includes:
[0065] When it is determined that the database operation list does not include the current data access layer, the next data access layer is determined.
[0066] In this embodiment, when it is determined that the database operation list does not include the current data access layer, the process is skipped and the next cycle is continued until all data access layers have established mapping relationships with database tables.
[0067] The technical solution provided by the present invention first obtains the project source code, finds the Java file from the project source code, and adds the Java file to the Java file list; then traverses the Java file list, finds the data access layer class name in the Java file list, obtains all the data access layer names under the data access layer class, and establishes a data access layer list; then traverses the Java file list, finds the database operation layer class name in the Java file list, obtains all the database table names under the database operation layer class and the data access layers used in the database operation layer class, and establishes a database operation list; finally, based on the data access layer list and the database operation list, establishes a mapping list. After modifying the program data access layer code, by tracing the database access interface file or database interface access configuration file under the data access layer, parsing the annotated SQL data in the interface file or the SQL statement in the database access configuration file, and extracting the database table name therefrom, the database-related tables that may be affected by the program data access layer modification are obtained, thereby determining the scope of the modification impact and more accurately monitoring and evaluating the changes and impacts of the related databases during the testing process.
[0068] Another embodiment of the present invention provides a mapping relationship search device, see Figure 4 The mapping relationship search device includes a source code acquisition module 11, a data access layer list establishment module 12, a database operation list establishment module 13 and a mapping list establishment module 14.
[0069] The source code acquisition module 11 is used to acquire the project source code, find a java file from the project source code, and add the java file to the java file list.
[0070] The data access layer list establishment module 12 is used to traverse the Java file list, find the data access layer class name in the Java file list, and obtain all data access layer names under the data access layer class, and then establish a data access layer list, wherein the data access layer list reflects the mapping relationship between the data access layer class name and the data access layer name.
[0071] The database operation list establishment module 13 is used to traverse the Java file list, find the database operation layer class name in the Java file list, and obtain all database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establish a database operation list, wherein the database operation list reflects the mapping relationship between the data access layer name, the database operation layer class name and the database table name.
[0072] The mapping list establishing module 14 is used to establish a mapping list based on the data access layer list and the database operation list, wherein the mapping list reflects the mapping relationship between the data access layer class name, the data access layer name and the database table name.
[0073] In this embodiment, the project source code is first obtained, a Java file is found from the project source code, and the Java file is added to a Java file list; then the Java file list is traversed to find the data access layer class name in the Java file list, and all the data access layer names under the data access layer class are obtained to establish a data access layer list; then the Java file list is traversed to find the database operation layer class name in the Java file list, and all the database table names under the database operation layer class and the data access layers used in the database operation layer class are obtained to establish a database operation list; finally, a mapping list is established based on the data access layer list and the database operation list. After modifying the program data access layer code, the database access interface file or database interface access configuration file under the data access layer is traced, the annotated SQL data in the interface file or the SQL statement in the database access configuration file is parsed, and the database table names therein are extracted, thereby obtaining the database-related tables that may be affected by the program data access layer modification, thereby determining the scope of the modification impact, and more accurately monitoring and evaluating the changes and impacts of the related databases during the testing process.
[0074] It should be noted that the module referred to in the present invention refers to a series of computer program instruction segments that can perform specific functions, which is more suitable for describing the execution process of mapping relationship search than a program. For the specific implementation methods of each module, please refer to the corresponding method embodiments above, which will not be repeated here.
[0075] In some embodiments, the data access layer list building module 12 is specifically used to:
[0076] Traversing the Java file list, converting the file names to lowercase, and finding the data access layer class file to obtain the data access layer class name;
[0077] The data access layer class file is parsed into an abstract syntax tree, all data access layers under the current data access layer class are obtained through a first regular expression, and after extracting the names of the data access layers, a data access layer list is established.
[0078] In some embodiments, the database operation list establishing module 13 is specifically used to:
[0079] Traversing the Java file list, converting the file names to lowercase, and finding the database operation layer class file to obtain the database operation layer class name;
[0080] The database operation layer class file is parsed into an abstract syntax tree, and after obtaining all database table names under the current data access layer class and the data access layer used in the database operation layer class through the second regular expression and the third regular expression respectively, a database operation list is established.
[0081] In some embodiments, the data access layer class file is a file ending with dto.
[0082] In some embodiments, the database operation layer class file is a file ending with mapper.
[0083] In some embodiments, the mapping list establishing module 14 is specifically configured to:
[0084] Traverse the data access layer list, judge each data access layer in the data access layer list in turn, and determine whether the current data access layer is included in the database operation list. If so, add the data access layer class name, data access layer name and corresponding database table name to the mapping list.
[0085] In some embodiments, the mapping list building module 14 is further configured to:
[0086] When it is determined that the database operation list does not include the current data access layer, the next data access layer is determined.
[0087] Another embodiment of the present invention provides an electronic device, such as Figure 5 As shown, the electronic device 10 includes:
[0088] One or more processors 110 and memory 120, Figure 5 In the description, a processor 110 is used as an example. The processor 110 and the memory 120 may be connected via a bus or other means. Figure 5 The bus connection is taken as an example.
[0089] The processor 110 is used to complete various control logics of the electronic device 10. It can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RICS Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. In addition, the processor 110 can also be any traditional processor, microprocessor, or state machine. The processor 110 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors combined with a DSP, and / or any other such configuration.
[0090] Memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs, and modules, such as program instructions corresponding to the mapping relationship search method in the embodiments of the present invention. Processor 110 executes the non-volatile software programs, instructions, and modules stored in memory 120 to execute various functional applications and data processing of electronic device 10, thereby implementing the mapping relationship search method in the above method embodiment.
[0091] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store an operating platform and applications required for at least one function; the data storage area may store data created based on the use of the electronic device 10, etc. In addition, the memory 120 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include a memory remotely located relative to the processor 110, and these remote memories may be connected to the electronic device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0092] One or more units are stored in the memory 120, and when executed by one or more processors 110, the mapping relationship search method in any of the above method embodiments is executed, for example, the mapping relationship search method described above is executed. Figure 1 Method steps S100 to S400.
[0093] Another embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions, which are executed by one or more processors, for example, to perform the above-described Figure 1 Method steps S100 to S400.
[0094] As an example, a computer-readable storage medium can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable ROM (EEPROM), or a flash memory. Volatile memory can include random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.
[0095] In summary, the mapping relationship search method, device, electronic device and storage medium provided by the present invention first obtain the project source code, find the Java file from the project source code, and add the Java file to the Java file list; then traverse the Java file list, find the data access layer class name in the Java file list, and obtain all the data access layer names under the data access layer class, and then establish a data access layer list; then traverse the Java file list, find the database operation layer class name in the Java file list, and obtain all the database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establish a database operation list; finally, based on the data access layer list and the database operation list, a mapping list is established. After modifying the program data access layer code, by tracing the database access interface file or database interface access configuration file under the data access layer, parsing the annotated SQL data in the interface file or the SQL statement in the database access configuration file, extracting the database table name therein, the database-related tables that may be affected by the modification of the program data access layer are obtained, thereby determining the scope of the modification impact, and more accurately monitoring and evaluating the changes and impacts of the relevant database during the testing process.
[0096] The specific embodiments of the present invention described above do not limit the scope of protection of the present invention. Any other corresponding changes and modifications made based on the technical concept of the present invention should be included in the scope of protection of the claims of the present invention.
Claims
1. A mapping relationship search method, characterized in that: The steps include: Obtain the project source code, find the Java file from the project source code, and add the Java file to the Java file list; Traversing the Java file list, finding the data access layer class name in the Java file list, and obtaining all data access layer names under the data access layer class, and then establishing a data access layer list, wherein the data access layer list reflects the mapping relationship between the data access layer class name and the data access layer name; Traversing the Java file list, finding the database operation layer class name in the Java file list, and obtaining all database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establishing a database operation list, wherein the database operation list reflects the mapping relationship between the data access layer name, the database operation layer class name and the database table name; A mapping list is established based on the data access layer list and the database operation list, wherein the mapping list reflects the mapping relationship between the data access layer class name, the data access layer name and the database table name.
2. The mapping relationship search method according to claim 1, characterized in that: The traversal of the java file list, finding the data access layer class name in the java file list, and obtaining all data access layer names under the data access layer class, then establishing a data access layer list, including: Traversing the Java file list, converting the file names to lowercase, and finding the data access layer class file to obtain the data access layer class name; The data access layer class file is parsed into an abstract syntax tree, all data access layers under the current data access layer class are obtained through a first regular expression, and after extracting the names of the data access layers, a data access layer list is established.
3. The mapping relationship search method according to claim 2, characterized in that: The traversal of the java file list, finding the database operation layer class name in the java file list, and obtaining all database table names under the database operation layer class and the data access layer used in the database operation layer class, then establishing a database operation list includes: Traversing the Java file list, converting the file names to lowercase, and finding the database operation layer class file to obtain the database operation layer class name; The database operation layer class file is parsed into an abstract syntax tree, and after obtaining all database table names under the current data access layer class and the data access layer used in the database operation layer class through the second regular expression and the third regular expression respectively, a database operation list is established.
4. The mapping relationship search method according to claim 3, characterized in that: The data access layer class file is a file ending with dto.
5. The mapping relationship search method according to claim 4, characterized in that: The database operation layer class file is a file ending with mapper.
6. The mapping relationship search method according to claim 5, characterized in that: The step of establishing a mapping list based on the data access layer list and the database operation list includes: Traverse the data access layer list, judge each data access layer in the data access layer list in turn, and determine whether the current data access layer is included in the database operation list. If so, add the data access layer class name, data access layer name and corresponding database table name to the mapping list.
7. The mapping relationship search method according to claim 6, characterized in that: Also includes: When it is determined that the database operation list does not include the current data access layer, the next data access layer is determined.
8. A mapping relationship search device, characterized in that: include: A source code acquisition module is used to obtain the project source code, find the Java file from the project source code, and add the Java file to the Java file list; a data access layer list establishment module, configured to traverse the Java file list, find the data access layer class name in the Java file list, obtain all data access layer names under the data access layer class, and then establish a data access layer list, wherein the data access layer list reflects the mapping relationship between the data access layer class name and the data access layer name; a database operation list establishment module, configured to traverse the Java file list, find the database operation layer class name in the Java file list, obtain all database table names under the database operation layer class and the data access layer used in the database operation layer class, and then establish a database operation list, wherein the database operation list reflects the mapping relationship between the data access layer name, the database operation layer class name and the database table name; The mapping list establishing module is used to establish a mapping list based on the data access layer list and the database operation list, wherein the mapping list reflects the mapping relationship between the data access layer class name, the data access layer name and the database table name.
9. An electronic device, characterized in that: include: processor and memory; The memory stores a computer program executable by the processor; When the processor executes the computer program, the steps of the mapping relationship search method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that include: processor and memory; The memory stores a computer program executable by the processor; When the processor executes the computer program, the steps of the mapping relationship search method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Database mapping file generation method and device, equipment and storage medium
CN114138748A
Data processing method and data processing device based on object relation mapping
CN114238527A