A method and apparatus for tracing database tables affected by database changes
By extracting and associating the method and table names of the data access layer and operation layer when the database changes, the problem of difficulty in tracing the impact of database changes is solved, and the rapid recording and verification of affected database tables is achieved, thus improving testing efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG ZEEKR INTELLIGENT TECH CO LTD
- Filing Date
- 2023-08-22
- Publication Date
- 2026-06-02
AI Technical Summary
When database changes occur, existing technologies cannot effectively record and trace the database tables affected by changes in data access layer methods, making it difficult for testers to monitor and verify the affected database tables.
By extracting the method names and database table names of the data access layer and data operation layer from project files, establishing associated storage, and recording the affected database tables, a method and apparatus are provided for tracing database tables affected by database changes.
It enables rapid tracing and recording of affected database tables when database changes occur, helping testers monitor and verify during the testing process, thus improving testing efficiency and accuracy.
Smart Images

Figure CN117112561B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of database technology, and in particular to a method and apparatus for tracing database tables affected by database changes. Background Technology
[0002] During software development, as data security requirements and system architecture upgrades increase, changes to the databases used in the project may be necessary, such as replacing Oracle with a domestic database. However, because the methods defined in the data access layer of this project have different operational logic for different databases, it is necessary to modify the corresponding data access layer methods to adapt to the changed database.
[0003] After modifying the methods defined in the data access layer, the relevant technologies do not record the database tables affected by the changes in the data access layer methods. Consequently, testers will retest all database tables in the changed database, including those that were not affected.
[0004] However, if the database project is large and the number of database tables affected by changes in the data access layer methods is too large, the lack of documentation of the affected database tables by the relevant technologies makes it difficult for testers to monitor and verify the affected database tables during the testing process. Summary of the Invention
[0005] To overcome the problems existing in related technologies, this specification provides a method and apparatus for tracing database tables affected by database changes.
[0006] According to a first aspect of the embodiments of this specification, a method for tracing database tables affected by database changes is provided, the method comprising:
[0007] If the database used in the project changes, retrieve the list of database-related files from the project files;
[0008] Retrieve files containing data access layer methods from the file list, extract the names of data operation layer methods from the files containing data access layer methods, and store them in the data access layer list.
[0009] Obtain the file containing the data operation layer method from the file list, extract the database table name and the data operation layer method name used by the data operation layer method from the file containing the data operation layer method, and store the database table name and the data operation layer method name in the data operation layer list in association;
[0010] If any data operation layer method name is present in both the data access layer list and the data operation layer list, then the database table name associated with that data operation layer method name in the data operation layer list is stored in the database table influence list.
[0011] According to a second aspect of the embodiments of this specification, an apparatus is provided for tracing database tables affected by database changes, comprising:
[0012] The retrieval module is used to retrieve a list of database-related files from the project files when the database used by the project changes.
[0013] The first extraction module is used to obtain files containing data access layer methods from the file list, extract the names of data operation layer methods from the files containing data access layer methods, and store them in the data access layer list.
[0014] The second extraction module is used to obtain a file containing data operation layer methods from the file list, extract the database table name and the data operation layer method name used by the data operation layer method in the file containing the data operation layer method, and associate and store the database table name and the data operation layer method name in the data operation layer list.
[0015] The recording module is used to store the database table name associated with any data operation layer method name in the data operation layer list into the database table influence list if any data operation layer method name is simultaneously in the data access layer list and the data operation layer list.
[0016] According to a third aspect of the embodiments of this specification, an electronic device is provided, 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 steps of the method as described in the first aspect.
[0017] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method as described in the first aspect.
[0018] The technical solutions provided in the embodiments of this specification may include the following beneficial effects:
[0019] In the embodiments of this specification, when the database used in the project changes, by extracting the names of the data operation layer methods from the file containing the data access layer methods, and by extracting the names of the data operation layer methods and database table names from the file containing the data operation layer methods, and based on the data operation layer method names common to the data access layer and the data operation layer, the database table names affected by the changes in the data access layer methods can be recorded. This can help testers monitor and verify the affected database tables during the testing process.
[0020] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of this specification.
[0022] Figure 1 This is a flowchart illustrating a method for tracing database tables affected by database changes, according to an exemplary embodiment of this specification.
[0023] Figure 2 This is a flowchart illustrating, according to an exemplary embodiment, another method for tracing database tables affected by database changes.
[0024] Figure 3 This is a flowchart illustrating, according to an exemplary embodiment, another method for tracing database tables affected by database changes.
[0025] Figure 4A This is sample code for a data access layer illustrated in this specification according to an exemplary embodiment.
[0026] Figure 4B This is example code for the data manipulation layer illustrated in this specification according to an exemplary embodiment.
[0027] Figure 5 This specification is a schematic diagram illustrating the structure of an electronic device according to an exemplary embodiment.
[0028] Figure 6 This is a block diagram illustrating an apparatus for tracing database tables affected by database changes, according to an exemplary embodiment of this specification. Detailed Implementation
[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed in the appended claims.
[0030] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0031] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0032] The embodiments described in this specification will now be described in detail.
[0033] like Figure 1 As shown, Figure 1 This specification is a flowchart illustrating a method for tracing database tables affected by database changes, according to an exemplary embodiment, comprising the following steps:
[0034] Step 101: If the database used in the project changes, obtain a list of database-related files from the project files;
[0035] In this context, a change in the database used in a project can refer to replacing the old database with a new one based on project requirements. For example, when a company's existing database can no longer meet new business needs due to changes in business requirements, it may replace the database for higher scalability, higher performance, and better data processing capabilities.
[0036] In one illustrated embodiment, files with the .java and .xml extensions obtained from the project file are added to the database-related file list. For example, a file named "DAOImpl.java" and a file named "database.xml" from the project file are added to the database-related file list.
[0037] The embodiments described in this specification determine the database-related file list by utilizing the file types identified by file extensions. Since the specific file types and organization of the database-related file list may vary depending on project requirements, framework selection, and technology stack, technicians can determine the database-related file list based on the actual project situation; this specification does not limit this approach.
[0038] Step 102: Obtain the file containing the data access layer method from the file list, extract the data operation layer method name from the file containing the data access layer method, and store it in the data access layer list;
[0039] Step 103: Obtain the file containing the data operation layer method from the file list, extract the database table name and the data operation layer method name used by the data operation layer method from the file containing the data operation layer method, and associate and store the database table name and the data operation layer method name in the data operation layer list.
[0040] In traditional software architecture layering, the data operation layer and the data access layer typically handle different functionalities. The data operation layer is primarily responsible for interacting directly with the database, defining the mapping rules between objects and database tables, including field mappings, relationships, and query statements. The data access layer references methods defined by the data operation layer; for example, the data access layer's code files or classes can be imported into its code files, allowing the data access layer to directly use the methods provided by the data operation layer.
[0041] In one illustrated embodiment, Java files whose names end in "dao" are identified from the file list as files containing data access layer methods. For example, a file named "*dao.java" is identified as a file containing data access layer methods, where "*" represents any character.
[0042] It should be noted that the file names retrieved in this specification are not case-sensitive. For example, a file named "*DAO.java" can be identified as containing data access layer methods.
[0043] In one illustrated embodiment, Java files whose names end with "mapper" and XML files whose names include "mapper" are retrieved from the file list to determine the files containing the data operation layer methods. Taking the MyBatis framework as an example, data operation layer methods are typically written in XML format and named "*mapper.xml", while in the Hibernate framework, data operation layer methods are usually configured using annotations or class-based mapping and named "*mapper.java", where "*" represents any character. Therefore, regardless of whether the data operation layer uses the MyBatis or Hibernate framework, or whether the data operation layer methods are written in XML format or using annotations in the mapper file, the method described in this embodiment can retrieve the files containing all data operation layer methods.
[0044] In one illustrated embodiment, the file containing the data manipulation layer methods can be a Java file ending with "mapper" or an XML file whose filename includes "mapper". For these two different file types, this embodiment provides a method for obtaining the names of the data manipulation layer methods and the names of the database tables used by the data manipulation layer methods from these two types of files:
[0045] If the file containing the data operation layer methods is a Java file whose filename ends with "mapper", then the Java file is parsed into an abstract syntax tree, and the data operation layer methods containing annotations are obtained based on the abstract syntax tree. The names of the data operation layer methods and the names of the database tables used by the data operation layer methods are also extracted.
[0046] If the file containing the data operation layer method is an XML file whose filename includes "mapper", then the XML file is parsed into an abstract syntax tree, and the names of the data operation layer methods and the database table names used by the data operation layer methods are further extracted.
[0047] Step 104: If any data operation layer method name is present in both the data access layer list and the data operation layer list, then store the database table name associated with the data operation layer method name in the data operation layer list into the database table influence list.
[0048] Since data manipulation layer methods exist in both the data access layer and the data manipulation layer, connections can be established between the data access layer and the data manipulation layer when code changes occur. For example, if the database used in the project changes, the data access layer may modify the operation logic for certain database tables. In this case, the affected database tables can be traced back from the data manipulation layer through the data manipulation layer methods called by the data access layer.
[0049] When facing large-scale software development projects, changes to the database used in the project often result in a massive amount of code modifications to the data access layer, affecting a large number of database tables. If testers are unaware of which database tables are affected, they will be unable to monitor and verify these tables during testing. The method for tracing database tables affected by database changes, as provided in this embodiment, allows for the rapid identification of all database tables affected by modifications to the data access layer code within the project framework when the database used in the project changes. These tables are then persistently saved to a database table impact list, which testers can use to monitor and verify the affected tables during testing.
[0050] Because the method for tracing database tables affected by database changes provided in the above embodiments only obtains the names of the database tables affected by changes in the data access layer, but does not establish the relationship between the affected database tables and the data access layer methods, when problems occur in the project code related to the data access layer, it is impossible to troubleshoot the database tables associated with the problematic data access layer methods, making it difficult to find the root cause of the problem.
[0051] In response to the above problems, such as Figure 2 As shown in the figure, this embodiment provides another method for tracing database tables affected by database changes. The specific steps are as follows:
[0052] Step 201: If the database used in the project changes, obtain a list of database-related files from the project files;
[0053] Step 202: Obtain the file containing the data access layer method from the file list, extract the data access layer method name, the data operation layer method name, and the name of the class containing the data access layer method from the file containing the data access layer method, and store them in the data access layer list.
[0054] It should be noted that the file containing data access layer methods obtained in step 202 may refer only to the file containing the data access layer methods whose code has been modified, or it may refer to the file containing all data access layer methods, including the file containing data access layer methods whose code has not been modified. The data access layer method names obtained from the file containing data access layer methods may refer only to the names of the data access layer methods whose code has been modified, or it may refer to the names of all data access layer methods. The data operation layer method names may refer only to the names of the data operation layer methods called by the data access layer methods whose code has been modified, or it may refer to the names of all data operation layer methods in the file containing data access layer methods. This specification does not impose any limitations on this.
[0055] In one illustrated embodiment, a file containing data access layer methods is parsed into an abstract syntax tree, and the names of the data access layer methods and the data operation layer methods are further obtained based on the abstract syntax tree.
[0056] In one illustrated embodiment, the filename containing the data access layer methods is determined to be the name of the class containing those methods. For example, if the filename containing the data access layer methods is "Class.java", then by extracting the filename "Class", the class containing the data access layer methods can be determined to be "Class".
[0057] Step 203: Obtain the file containing the data operation layer method from the file list, extract the database table name and the data operation layer method name used by the data operation layer method from the file containing the data operation layer method, and store the database table name and the data operation layer method name in the data operation layer list.
[0058] Step 204: If any data operation layer method name is present in both the data access layer list and the data operation layer list, then associate the data access layer method name stored in the data access layer list with the name of the class to which the data access layer method belongs, and the database table name stored in the data operation layer list with the name of the database table to which the data operation layer method name is stored, and store them in the database table influence list.
[0059] In this embodiment, the relationship between the data access layer method and the underlying database table is established by obtaining the data access layer method name, the name of the class in which the data access layer method is located, and the database table name. Therefore, when a problem occurs in the project code related to the data access layer, the root cause of the problem can be found by tracing the relationship between the problematic data access layer method and its associated database table.
[0060] Next, combined Figure 3 , Figure 4A and Figure 4B Taking a Java development project as an example, this document provides a specific implementation of a method for tracing database tables affected by database changes:
[0061] Step 301: Obtain the Java project source code;
[0062] The project source code refers to the project files after the database used by the project has been changed.
[0063] Step 302: Traverse the files with the extension ".java" and ".xml" in the project source code, and add all files that meet the criteria to the file list associated with the database;
[0064] Step 303: Convert all file names to lowercase.
[0065] Understandably, to avoid errors caused by inconsistent filename case, filenames can be uniformly converted to lowercase. Alternatively, all filenames can be uniformly converted to uppercase. This instruction manual does not impose any restrictions.
[0066] Step 304: Obtain the file whose name ends with "dao" from the file list, and extract the data access layer method name, the name of the class where the data access layer method is located, and the data operation layer method name from the file, and store them in the data access layer list.
[0067] The following is based on Figure 4A Let's take the code in the example to illustrate step 304:
[0068] like Figure 4A , Figure 4A The class UserDao, which contains the data access layer methods, is located in a file named "UserDao.java". This class defines two data access layer methods, addUser and moveUser, which execute the operation logic of adding and deleting users in the database table by calling the data operation layer methods insertUser and deleteUser, respectively.
[0069] The file can be parsed into an abstract syntax tree using Java syntax. Based on this abstract syntax tree, the names of the data access layer methods `addUser` and `moveUser`, and the names of the data manipulation layer methods `insertUser` and `deleteUser`, can be obtained. For example, based on the parsed abstract syntax tree, all methods in the current class can be retrieved using the regular expression ` / MethodDeclarator[*]`, and the method names can be extracted one by one using the `@image` attribute.
[0070] Step 305: Obtain Java files whose file names end with "mapper" and XML files whose file names include "mapper" from the file list. Obtain the data operation layer methods and the database tables used by the data operation layer methods from the above two types of files, and store them in the data operation layer list.
[0071] The following example uses Java files whose names end with "mapper". Figure 4B As shown, the Java file named "DataMapper" contains the data manipulation layer methods insertUser and deleteUser, as well as the database table User used by the data manipulation layer methods.
[0072] Specifically, the file can be parsed into an abstract syntax tree using Java syntax. The regular expression ` / [Anotation[name="select / insert / update"] / Membervalue / literal[*]` can be used to obtain the methods `insertUser` and `deleteUser` in the current class that contain the `select / insert / update` annotation. These annotated methods are data operation layer methods `insertUser` and `deleteUser` that operate on the database table `User`. Correspondingly, the name of the database table `User` can be obtained, and the data operation layer methods `insertUser` and `deleteUser` used in the database operation class can be obtained using ` / [Anotation[name="select / insert / update"] / Membervalue / ClassOrInterfaceType[*]`.
[0073] Step 306: If any data operation layer method name is present in both the data access layer list and the data operation layer list, then associate the data access layer method name stored in the data access layer list with the name of the class to which the data access layer method belongs, and the database table name stored in the data operation layer list with the name of the database table to which the data operation layer method name is stored, and store them in the database table influence list.
[0074] In step 306, it can be determined that the data operation layer methods insertUser and deleteUser exist in both the data operation layer list and the data access layer list. Finally, it can be determined that the database table User is the affected database table. It can be associated with the data access layer methods addUser and moveUser, as well as the class UserDao in which the data access layer methods are located, and stored in the database table affected list.
[0075] Corresponding to the embodiments of the foregoing methods, this specification also provides embodiments of the apparatus and the terminal to which it is applied.
[0076] like Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of an electronic device provided in an exemplary embodiment. At the hardware level, the device includes a processor 502, an internal bus 504, a network interface 506, memory 508, and non-volatile memory 510, and may also include other hardware required for various services. One or more embodiments of this specification can be implemented in software, for example, the processor 502 reads the corresponding computer program from the non-volatile memory 510 into memory 508 and then runs it. Of course, besides software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution entity of the following processing flow is not limited to individual logic modules, but can also be hardware or logic devices.
[0077] like Figure 6 As shown, Figure 6 This is a block diagram illustrating an apparatus for tracing database tables affected by database changes, according to an exemplary embodiment of this specification. This apparatus can be applied to, for example... Figure 5 The electronic device shown implements the technical solution of this specification. The device includes:
[0078] Module 601 is used to retrieve a list of database-related files from the project files when the database used by the project changes.
[0079] The first extraction module 602 is used to obtain files containing data access layer methods from the file list, extract the data operation layer method names from the files containing data access layer methods, and store them in the data access layer list.
[0080] The second extraction module 603 is used to obtain a file containing data operation layer methods from the file list, extract the database table name and the data operation layer method name used by the data operation layer method in the file containing the data operation layer method, and associate and store the database table name and the data operation layer method name in the data operation layer list.
[0081] The recording module 604 is used to store the database table name associated with any data operation layer method name in the data operation layer list into the database table influence list if any data operation layer method name is simultaneously in the data access layer list and the data operation layer list.
[0082] In one illustrated embodiment, the acquisition module 601 is specifically used to acquire files with the file extensions .java and .xml from the project file and add them to the database-related file list.
[0083] In one illustrated embodiment, the acquisition module 601 is specifically configured to acquire Java files whose file names end with "dao" from the file list; and to acquire Java files whose file names end with "mapper" and XML files whose file names include "mapper" from the file list.
[0084] In one illustrated embodiment, the second extraction module 603 is specifically configured to: if the file containing the data operation layer method is a Java file whose filename ends with "mapper", then parse the Java file into an abstract syntax tree, further obtain the data operation layer method containing annotations based on the abstract syntax tree, and extract the name of the data operation layer method and the name of the database table used by the data operation layer method; if the file containing the data operation layer method is an XML file whose filename includes "mapper", then parse the XML file into an abstract syntax tree, and further extract the name of the data operation layer method and the name of the database table used by the data operation layer method.
[0085] In one illustrated embodiment, the first extraction module 602 is specifically used to extract the data access layer method name, the data operation layer method name, and the name of the class containing the data access layer method from the file containing the data access layer method, and store them in the data access layer list; the recording module 604 is specifically used to associate the data access layer method name and the name of the class containing the data operation layer method stored in the data access layer list with the database table name stored in the data operation layer list with the database table influence list.
[0086] In one illustrated embodiment, the first extraction module 602 is specifically used to parse the file containing the data access layer method into an abstract syntax tree, and further obtain the data access layer method name and the data operation layer method name based on the abstract syntax tree.
[0087] In one illustrated embodiment, the first extraction module 602 is specifically used to determine the file name containing the data access layer method as the name of the class in which the data access layer method is located.
[0088] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0089] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0090] This specification also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the foregoing methods for tracing database tables affected by database changes provided in this application.
[0091] Specifically, computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks.
[0092] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0093] Other embodiments of this specification will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This specification is intended to cover any variations, uses, or adaptations that follow the general principles of this specification and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this specification are indicated by the following claims.
[0094] It should be understood that this specification is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this specification is limited only by the appended claims.
[0095] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.
Claims
1. A method for tracing database tables affected by database changes, characterized in that, The method includes: If the database used in the project changes, retrieve the list of database-related files from the project files; The file containing the data access layer method is obtained from the file list. The names of the data operation layer methods in the file containing the data access layer method are extracted and stored in the data access layer list. The step of extracting the names of the data operation layer methods in the file containing the data access layer method and storing them in the data access layer list includes: extracting the names of the data access layer methods, the names of the data operation layer methods, and the names of the classes in which the data access layer methods are located from the file containing the data access layer method, and storing them in association in the data access layer list. Obtain the file containing the data operation layer method from the file list, extract the database table name and the data operation layer method name used by the data operation layer method from the file containing the data operation layer method, and store the database table name and the data operation layer method name in the data operation layer list in association; If any data operation layer method name is present in both the data access layer list and the data operation layer list, then the database table name associated with that data operation layer method name in the data operation layer list is stored in the database table influence list. Storing the database table name associated with that data operation layer method name in the data operation layer list into the database table influence list includes: associating the data access layer method name associated with that data operation layer method name in the data access layer list and the name of the class containing that data access layer method with the database table name associated with that data operation layer method name in the data operation layer list, and storing them together in the database table influence list.
2. The method according to claim 1, characterized in that, The step of retrieving the database-related file list from the project files includes: Files with the .java and .xml extensions obtained from the project files are added to the database-related file list.
3. The method according to claim 2, characterized in that, The step of retrieving the file containing the data access layer method from the file list includes: Retrieve Java files whose names end with "dao" from the file list; The step of retrieving the file containing the data manipulation layer method from the file list includes: Retrieve Java files whose names end with "mapper" and XML files whose names include "mapper" from the file list.
4. The method according to claim 3, characterized in that, The step of extracting the database table name and the data operation layer method name used by the data operation layer method from the file containing the data operation layer method includes: If the file containing the data operation layer method is a Java file whose file name ends with mapper, then the Java file is parsed into an abstract syntax tree, and the data operation layer method containing annotations is obtained based on the abstract syntax tree, and the name of the data operation layer method and the name of the database table used by the data operation layer method are extracted. If the file containing the data operation layer method is an XML file whose filename includes "mapper", then the XML file is parsed into an abstract syntax tree, and the names of the data operation layer methods and the database table names used by the data operation layer methods are further extracted.
5. The method according to claim 1, characterized in that, The extraction of the data access layer method name and the data operation layer method name from the file containing the data access layer methods includes: The file containing the data access layer methods is parsed into an abstract syntax tree, and the names of the data access layer methods and the data operation layer methods are obtained based on the abstract syntax tree.
6. The method according to claim 1, characterized in that, Extracting the name of the class containing the data access layer methods from the file containing the data access layer methods, including: The file name containing the data access layer methods is determined to be the name of the class containing those data access layer methods.
7. An apparatus for tracing database tables affected by database changes, characterized in that, include: The retrieval module is used to retrieve a list of database-related files from the project files when the database used by the project changes. The first extraction module is used to obtain files containing data access layer methods from the file list, extract the names of data operation layer methods from the files containing data access layer methods, and store them in the data access layer list. The step of extracting the data operation layer method name from the file containing the data access layer method and storing it in the data access layer list includes: extracting the data access layer method name, the data operation layer method name, and the name of the class containing the data access layer method from the file containing the data access layer method, and storing them in association in the data access layer list. The second extraction module is used to obtain a file containing data operation layer methods from the file list, extract the database table name and the data operation layer method name used by the data operation layer method in the file containing the data operation layer method, and associate and store the database table name and the data operation layer method name in the data operation layer list. A recording module is configured to, if any data operation layer method name is simultaneously present in both the data access layer list and the data operation layer list, store the database table name associated with that data operation layer method name in the data operation layer list into a database table influence list; the step of storing the database table name associated with that data operation layer method name in the data operation layer list into the database table influence list includes: associating the data access layer method name associated with that data operation layer method name in the data access layer list and the name of the class to which the data access layer method belongs with the database table name associated with that data operation layer method name in the data operation layer list, and storing them together in the database table influence list.
8. 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 steps of the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.