Data comparison method and device

By automatically comparing the data table mapping information and field information of the persistent object, the resource waste and performance problems caused by unused data columns in the database are solved, and efficient database resource management is achieved.

CN118760680APending Publication Date: 2024-10-11BEIJING PACTERA JINXIN TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410832479.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

In the software development life cycle, unused data columns in the database lead to resource waste and performance degradation. Existing technologies rely on manual data comparison, which is inefficient and inaccurate.

Method used

Provide a data comparison method and device, which determines whether there is a matching data table in the target database by obtaining the data table mapping information and field information of the persistent object, compares the field information with the table structure, and generates difference information to Identify unused data columns.

Benefits of technology

It achieves accurate and timely identification of unused data columns in the database, avoids resource waste and performance degradation, improves the accuracy of data table mapping and field information, and saves database resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760680A_ABST
    Figure CN118760680A_ABST
Patent Text Reader

Abstract

The invention provides a data comparison method and device, and the method comprises the steps: obtaining data table mapping information and field information of at least one persistent object in response to the existence of at least one persistent object in a target business application; judging whether at least one target database exists or not according to the system configuration information; in response to the existence of the at least one target database, for any persistent object, according to the data table mapping information of any persistent object, judging whether at least one target data table matched with the data table mapping information of any persistent object exists in the at least one target database or not; if yes, obtaining a table structure of at least one target data table; and comparing the field information of any persistent object with the at least one table structure to generate and display the difference information, so that the unused data columns in the database can be identified timely and accurately, and the waste of database resources and the performance degradation caused by the unused data columns are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a data comparison method and device. Background Art

[0002] In the software development life cycle, the database is one of the core components. In the process of continuous iteration of application system functions, the entities (persistent objects, referred to as PO) in business applications and the fields in the entities often change. Due to development progress and other reasons, the data tables in the database and the column information in the data tables may not be synchronized with the changes in PO, resulting in unused data columns in the database, causing a waste of database resources.

[0003] In order to avoid wasting database resources and performance degradation caused by unused data columns, data comparison is required between the database and PO to determine the unused data columns in the database. Therefore, how to perform data comparison is very important. Summary of the invention

[0004] The present disclosure provides a data comparison method and device to at least solve one of the technical problems in the related art to a certain extent. The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, a data comparison method is provided, comprising: in response to the existence of at least one persistent object in a target business application, obtaining data table mapping information and field information of the at least one persistent object; judging, based on system configuration information, whether there is at least one target database, wherein the target database is used for data storage of the target business application; in response to the existence of at least one target database, for any persistent object among the at least one persistent object, judging, based on the data table mapping information of any persistent object, whether there is at least one target data table in the at least one target database that matches the data table mapping information of any persistent object; in response to the existence of the at least one target data table, obtaining a table structure of the at least one target data table; comparing the field information of any persistent object with the at least one table structure to generate and display difference information between the field information of any persistent object and the at least one table structure.

[0006] According to a second aspect of an embodiment of the present disclosure, a data comparison device is provided, comprising: a first acquisition module, for, in response to the existence of at least one persistent object in a target business application, acquiring data table mapping information and field information of the at least one persistent object; a first judgment module, for judging, based on system configuration information, whether there is at least one target database, wherein the target database is used for data storage in the target business application; a second judgment module, for, in response to the existence of at least one target database, for any persistent object in the at least one persistent object, judging, based on the data table mapping information of any persistent object, whether there is at least one target data table in the at least one target database that matches the data table mapping information of any persistent object; a second acquisition module, for, in response to the existence of the at least one target data table, acquiring the table structure of the at least one target data table; and a comparison module, for comparing the field information of any persistent object with the at least one table structure, so as to generate and display difference information between the field information of any persistent object and the at least one table structure.

[0007] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the data comparison method as described in the embodiment of the first aspect of the present disclosure.

[0008] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the data comparison method as described in the embodiment of the first aspect of the present disclosure.

[0009] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising: a computer program, wherein when the computer program is executed by a processor, the data comparison method as described in the embodiment of the first aspect of the present disclosure is implemented.

[0010] In the technical solution, by judging whether there is a target database for storing data of the target business application, and when there is at least one target database, for any persistent object of the target business application, judging whether there is a target data table in the at least one target database that matches the data mapping information of any persistent object, if so, the field information of any persistent object is compared with the corresponding at least one table structure to obtain the difference information between the field information of any persistent object and the at least one table structure, so that the unused data columns in the database can be accurately and timely determined according to the difference information to avoid the waste of database resources and the performance degradation caused by the unused data columns (such as redundant data columns); wherein, by performing reflection analysis on the mapping annotation information, parent class and child class of any persistent object, the data table mapping information and field information of at least one persistent object are obtained, thereby improving the accuracy of the data table mapping information and field information, and at the same time, based on the type of the database where the target data table is located, the corresponding target column information query code is used to obtain at least one table structure, thereby improving the accuracy of the at least one table structure, thereby further improving the accuracy of the difference information between the field information of the persistent object and the at least one table structure, and more effectively saving database resources.

[0011] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0013] Figure 1 is a flow chart of a data comparison method shown in the first embodiment of the present disclosure;

[0014] Figure 2 is a flow chart of a data comparison method shown in the second embodiment of the present disclosure;

[0015] Figure 3 is a flow chart of a data comparison method shown in the third embodiment of the present disclosure;

[0016] Figure 4 is a flow chart of a data comparison method shown in the fourth embodiment of the present disclosure;

[0017] Figure 5 is a flow chart of a data comparison method shown in the fifth embodiment of the present disclosure;

[0018] Figure 6 It is a schematic diagram of the scanning process principle of a persistent object shown in an embodiment of the present disclosure;

[0019] Figure 7 It is a schematic diagram of the principle of the database scanning process shown in the embodiment of the present disclosure;

[0020] Figure 8 is a structural schematic diagram of a data comparison device shown in the sixth embodiment of the present disclosure;

[0021] Fig. 9 It is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0022] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0024] It should be noted that in the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are all carried out with the user's consent, and are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0025] In the related art, data comparison between the database and the PO is usually performed manually, which results in low data comparison efficiency and poor accuracy.

[0026] In view of the above problems, the present disclosure proposes a data comparison method.

[0027] The data comparison method and device of the embodiments of the present disclosure are described below with reference to the accompanying drawings.

[0028] Figure 1 It is a flowchart of the data comparison method shown in the first embodiment of the present disclosure.

[0029] like Figure 1 As shown, the data comparison method may include the following steps:

[0030] Step 101: in response to at least one persistent object existing in a target business application, data table mapping information and field information of the at least one persistent object are acquired.

[0031] As a possible implementation method, the code of the target business application is parsed to determine whether there is at least one persistent object in the target business application. If there is at least one persistent object in the target business application, data table mapping information and field information of the at least one persistent object are obtained, wherein the data table mapping information is identification information in the persistent object for identifying the data table, such as @Table table name, and the field information includes basic fields and business fields. The basic fields include: creator, modifier, etc., and the business fields include fields corresponding to the business, such as name, age, gender, etc.

[0032] As another possible implementation method, the annotation information of the target business application is parsed to determine whether there is at least one persistent object in the target business application. If there is at least one persistent object in the target business application, data table mapping information and field information of the at least one persistent object are obtained.

[0033] Step 102: Determine whether there is at least one target database according to the system configuration information.

[0034] The target database is used for data storage of target business applications.

[0035] As a possible implementation manner, the system configuration information is parsed to determine whether there is at least one target database for storing data for the target business application.

[0036] Step 103, in response to the existence of at least one target database, for any persistent object among the at least one persistent object, based on the data table mapping information of any persistent object, determine whether there is at least one target data table in the at least one target database that matches the data table mapping information of any persistent object.

[0037] As a possible implementation method, when there is at least one target database, a database link of the at least one target database can be obtained, and for any persistent object in the target business application, based on the data table mapping information of any persistent object, it is determined whether there is at least one target data table in the at least one target database under the database link that matches the data table mapping information of any persistent object.

[0038] Step 104: in response to the existence of at least one target data table, obtaining a table structure of the at least one target data table.

[0039] As a possible implementation, if at least one target data table matching the data table mapping information of any persistent object exists in at least one target database, for any target database, according to the type of the any target database, the table structure of the target data table is obtained from the any target database. The table structure of the at least one target data table includes column names, data types, data lengths, whether null values ​​are allowed, etc. As another possible implementation, if at least one target data table matching the data table mapping information of any persistent object does not exist in at least one target database, it can be indicated that the data table of the at least one target database is a data table not used by the target business application.

[0040] Step 105: compare the field information of any persistent object with at least one table structure to generate and display difference information between the field information of any persistent object and at least one table structure.

[0041] Furthermore, the field information of any persistent object is compared with the corresponding at least one table structure, thereby generating difference information between the field information of any persistent object and the at least one table structure. In order to enable relevant personnel to understand the difference information more intuitively, as an example, the difference information is displayed on a visual interface, and in addition, a difference report can be generated based on the difference information, and the difference report is sent to relevant personnel.

[0042] In summary, by judging whether there is a target database for storing data of the target business application, and when there is at least one target database, for any persistent object of the target business application, judging whether there is a target data table in at least one target database that matches the data mapping information of any persistent object, if so, the field information of any persistent object is compared with the corresponding at least one table structure to obtain the difference information between the field information of any persistent object and the at least one table structure, so that the unused data columns in the database can be accurately and timely determined according to the difference information, so as to avoid the waste of database resources and the performance degradation caused by the unused data columns (such as the redundant data columns).

[0043] In order to clearly explain how to obtain the table structure of at least one target data table when there is at least one target data table in the above embodiment, the present disclosure proposes another data comparison method.

[0044] Figure 2 It is a flowchart of the data comparison method shown in the second embodiment of the present disclosure.

[0045] like Figure 2 As shown, the data comparison method may include the following steps:

[0046] Step 201: in response to at least one persistent object existing in the target business application, data table mapping information and field information of the at least one persistent object are obtained.

[0047] Step 202: Determine whether there is at least one target database according to the system configuration information.

[0048] The target database is used for data storage of target business applications.

[0049] Step 203, in response to the existence of at least one target database, for any persistent object among the at least one persistent object, based on the data table mapping information of any persistent object, determine whether there is at least one target data table in the at least one target database that matches the data table mapping information of any persistent object.

[0050] Step 204: for any target data table in the at least one target data table, determine the database type of the database where any target data table is located.

[0051] As a possible implementation manner, a database type of a database where each target data table in at least one target data table is located is obtained, wherein the database type includes but is not limited to: MySQL8, Oracle, and SQLServer, etc.

[0052] Step 205 : acquiring a target column information query code that matches the database type of the database where any target data table is located from the plurality of candidate column information query codes.

[0053] As a possible implementation, different database types correspond to different column information query codes. As an example, a target column information query code matching the database type of a database where any target data table is located is obtained from multiple candidate column information query codes.

[0054] For example, taking the database type as MySQL8, the target column information query code matching MySQL8 is "INFORMATION_SCHEMA.COLUMNS"; taking the database type as Oracle, the target column information query code matching Oracle is "ALL_TAB_COLUMNS"; taking the database type as SQLServer, the target column information query code matching SQLServer is "INFORMATION_SCHEMA.COLUM NS".

[0055] Step 206: execute the target column information query code to obtain the table structure of any target data table.

[0056] Furthermore, the target column information query code is executed to read the table structure of any target data table.

[0057] In addition, it should be noted that, in order to facilitate subsequent query operations on data tables in the database, when the table structure of at least one target data table is obtained, the table structure of at least one target data table may be stored.

[0058] As an example, the table objects of databases such as MySQL, Oracle, and SQLServer are converted into a unified database table object, where the object is independent of the specific database type. The unified database table object is stored, and a unified visual query page can also be provided to manage data tables in all databases and trace historical versions of data tables in the database.

[0059] Step 207: compare the field information of any persistent object with at least one table structure to generate and display difference information between the field information of any persistent object and at least one table structure.

[0060] It should be noted that the execution process of steps 201 to 203 and step 207 can be implemented in any way in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0061] In summary, by determining the database type of the database where any target data table is located for any target data table in at least one target data table; obtaining a target column information query code that matches the database type of the database where any target data table is located from multiple candidate column information query codes; executing the target column information query code to obtain the table structure of any target data table, thereby, according to the different database types of the database where the target data table is located, different target column information query codes are used to accurately and effectively obtain the table structure of the target data table.

[0062] In order to clearly explain how to obtain data table mapping information and field information of at least one persistent object when there is at least one persistent object in the target business application in the above embodiment, the present disclosure proposes another data comparison method.

[0063] Figure 3 It is a flowchart of the data comparison method shown in the third embodiment of the present disclosure.

[0064] like Figure 3 As shown, the data comparison method may include the following steps:

[0065] Step 301 , in response to at least one persistent object existing in the target business application, reflection parsing is performed on mapping annotation information of any persistent object to obtain data table mapping information of any persistent object.

[0066] As a possible implementation, when there is at least one persistent object in the target business application, the mapping annotation information in the annotation information of any persistent object is reflected and parsed to obtain the data table mapping information of any persistent object, wherein the mapping annotation information is annotation information used to mark the data table mapping information.

[0067] Step 302: Perform reflection analysis on the parent class of any persistent object to obtain the basic fields of any persistent object.

[0068] It should be understood that in order to avoid repeated definition of basic fields in multiple persistent objects under the target business application, as an example, the parent class is used to uniformly define the basic fields. Therefore, the parent class of any persistent object is reflectively parsed to obtain the basic fields of any persistent object.

[0069] Step 303: Perform reflection analysis on the subclass where any persistent object is located to obtain the business field of any persistent object.

[0070] As a possible implementation method, in order to distinguish the business fields of each persistent object, a subclass is used to define the business fields of each persistent object. Therefore, the subclass where any persistent object is located is reflected and parsed to obtain the business fields of any persistent object.

[0071] Step 304: Determine the field information of any persistent object according to the basic fields and business fields of any persistent object.

[0072] As a possible implementation method, the basic fields and business fields are traversed in sequence, and the attribute annotation information of the currently traversed field is obtained according to the currently traversed field; the attribute annotation information is parsed to determine whether the attribute annotation information includes the column information annotation; in response to the attribute annotation information including the column information annotation, the column information annotation is reflectively parsed to obtain the mapping field and attribute information of the currently traversed field; wherein the mapping field is used to indicate the display format of the currently traversed field in the corresponding data table; the field information of any persistent object is determined according to the mapping field and attribute information of the basic field of any persistent object and the attribute information of the business field.

[0073] For example, taking the @ApiModelProperty annotation information of Swagger as an example, the @ApiModelProperty annotation information of Swagger is parsed to determine whether there is @Column column annotation information. If there is @Column column annotation information, the @Column column annotation is reflectively parsed to obtain the mapping field and attribute information of the currently traversed field, where the mapping field is used to indicate the display format of the currently traversed field in the corresponding data table. For example, the currently traversed field is named in camel case, and the camel case named field can be modified to underscore, that is, the currently traversed field is "useName" and the corresponding mapping field is "user_name".

[0074] As another possible implementation method, in response to the fact that the attribute annotation information does not include the column information annotation, for the currently traversed field, a base field matching the currently traversed field is obtained; based on the base field matching the currently traversed field, the currently traversed field is formatted to obtain a mapping field of the currently traversed field; and based on the mapping field of the base field of any persistent object and the mapping field of the business field, the field information of any persistent object is determined.

[0075] That is to say, if the attribute annotation information does not include column annotation information, the format of the currently traversed field can be converted according to the base field to obtain the mapping field, such as changing the camel case name of the field to an underscore as the field name, so that the mapping field of the basic field of any persistent object and the mapping field of the business field are used as the field information of any persistent object.

[0076] Step 305: Determine whether there is at least one target database according to the system configuration information.

[0077] The target database is used for data storage of target business applications.

[0078] Step 306, in response to the existence of at least one target database, for any persistent object among the at least one persistent object, based on the data table mapping information of any persistent object, determine whether there is at least one target data table in the at least one target database that matches the data table mapping information of any persistent object.

[0079] Step 307: In response to the existence of at least one target data table, obtain the table structure of the at least one target data table.

[0080] Step 308: compare the field information of any persistent object with at least one table structure to generate and display difference information between the field information of any persistent object and at least one table structure.

[0081] It should be noted that the execution process of step 305 to step 308 can be implemented in any way in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0082] In summary, in response to the existence of at least one persistent object in the target business application, the mapping annotation information of any persistent object is reflectively parsed to obtain the data table mapping information of any persistent object; the parent class of any persistent object is reflectively parsed to obtain the basic fields of any persistent object; the subclass of any persistent object is reflectively parsed to obtain the business fields of any persistent object; the field information of any persistent object is determined based on the basic fields and business fields of any persistent object. Therefore, by reflectively parsing the mapping annotation information, parent class and subclass of any persistent object, the field information of any persistent object can be accurately and effectively obtained.

[0083] In order to clearly illustrate how, in the above embodiment, when there is at least one target database, for any persistent object among at least one persistent object, based on the data table mapping information of any persistent object, it is determined whether there is at least one target data table in the at least one target database that matches the data table mapping information of any persistent object, the present disclosure proposes another data comparison method.

[0084] Figure 4 It is a flowchart of the data comparison method shown in the fourth embodiment of the present disclosure.

[0085] like Figure 4 As shown, the data comparison method may include the following steps:

[0086] Step 401: In response to at least one persistent object existing in the target business application, data table mapping information and field information of the at least one persistent object are obtained.

[0087] Step 402: Determine whether there is at least one target database based on the system configuration information.

[0088] The target database is used for data storage of target business applications.

[0089] Step 403: In response to the existence of at least one target database, a database link of any target database is obtained.

[0090] As a possible implementation method, when there is at least one target database, determine whether there is a data access template in the configuration container associated with the target business application; when there is a data access template, obtain the database link of any target database according to the data access template.

[0091] For example, it is determined whether a data access template JdbcTemplate exists in the configuration container associated with the target business application. If JdbcTemplate exists in the configuration container associated with the target business application, a database link of any target database is determined based on JdbcTemplate.

[0092] As another possible implementation method, in the absence of a data access template, determine whether there is a data source associated with the target business application; if a data source exists, obtain a database link of any target database from the data source; if no data source exists, create a database link of any target database based on configuration information associated with any target database.

[0093] For example, if there is no data access template, determine whether there is a data source DataSource associated with the target business application. If there is a DataSource, the DataSource includes a database link of any target database. Therefore, the database link of any target database is obtained from the data source; if there is no DataSource, create a jdbc link based on the configuration information associated with any target database.

[0094] Step 404: for any persistent object, based on the data table mapping information of any persistent object, determine whether there is at least one target data table in any target database under the database link.

[0095] It should be understood that the data table mapping information of each persistent object can correspond to at least one target data table in at least one target database. Therefore, in order to accurately determine whether there is at least one target data table in the target database, as an example, for any persistent object, it can be determined whether there is at least one target data table in any target database under the database link based on the data table mapping information of any persistent object.

[0096] Step 405: In response to the existence of at least one target data table, obtain the table structure of at least one target data table.

[0097] Step 406: compare the field information of any persistent object with at least one table structure to generate and display difference information between the field information of any persistent object and at least one table structure.

[0098] It should be noted that the execution process of step 401 to step 402 and step 405 to step 406 can be implemented in any way in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be repeated.

[0099] In summary, in response to the existence of at least one target database, the database link of any target database is obtained; for any persistent object, according to the data table mapping information of any persistent object, it is determined whether there is at least one target data table in any target database under the database link, thereby accurately and effectively determining whether there is at least one target data table in the target database.

[0100] In order to avoid the waste of database resources, as an example, after displaying the difference information, the target data table in the database can be processed according to the difference information. Figure 5 Provide detailed explanation.

[0101] Figure 5 It is a flowchart of the data comparison method shown in the fifth embodiment of the present disclosure.

[0102] like Figure 5 As shown, the data comparison method may include the following steps:

[0103] Step 501: In response to at least one persistent object existing in the target business application, data table mapping information and field information of the at least one persistent object are obtained.

[0104] Step 502: Determine whether there is at least one target database based on the system configuration information.

[0105] The target database is used for data storage of target business applications.

[0106] Step 503, in response to the existence of at least one target database, for any persistent object among the at least one persistent object, based on the data table mapping information of any persistent object, determine whether there is at least one target data table in the at least one target database that matches the data table mapping information of any persistent object.

[0107] Step 504: in response to the existence of at least one target data table, obtain the table structure of the at least one target data table.

[0108] Step 505: compare the field information of any persistent object with at least one table structure to generate and display difference information.

[0109] Step 506: In response to the difference information indicating that the target field information exists in the field information, insert column information matching the target field information into at least one target data table.

[0110] Among them, the target field information does not match at least one table structure.

[0111] As a possible implementation method, if the difference information indicates that there is target field information in the field information, and there is no column information matching the target field information in at least one table structure, then column information matching the target field information is inserted into at least one target data table.

[0112] Step 507: In response to the difference information indicating that the target column information exists in at least one data table structure, the target column information is deleted from at least one target data table.

[0113] Among them, the target column information does not match the field information.

[0114] As another possible implementation method, there is target column information in at least one data table structure of the difference information, but there is no field matching the target column information in the field information, that is, there is redundant column information in at least one target data table. Therefore, the target column information can be deleted in at least one target data table.

[0115] It should be noted that the execution process of step 501 to step 505 can be implemented in any way in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0116] In summary, in response to the difference information indicating that the target field information exists in the field information, column information matching the target field information is inserted into at least one target data table; in response to the difference information indicating that the target column information exists in at least one data table structure, the target column information is deleted from at least one target data table. Thus, based on the comparison information, database resources can be effectively saved.

[0117] Based on any embodiment of the present disclosure, in the actual implementation process, the data comparison method of the embodiment of the present disclosure can be implemented based on the following steps:

[0118] 1. Scan at least one persistent object of the target business application to obtain the data table mapping information and field information (including business fields and basic fields) of at least one persistent object

[0119] The scanning process of the target business application's persistent objects is as follows: Figure 6 As shown, the specific steps are as follows:

[0120] (1) Use the general function of the scanner to obtain all persistent objects under the persistent object path, and then convert them into objects;

[0121] (2) Reflection analysis @Table table name (data table mapping information);

[0122] (3) Analyze basic fields, including ID, creator, creation time, modifier, modification time, tenant, etc.

[0123] (4) Parse the current class business field;

[0124] (5) Traverse the basic fields and business fields in turn. During the traversal process, parse the @ApiModelProperty annotation of Swagger to determine whether the annotation information includes the column annotation information @Column; if the column annotation information @Column is included, take the attributes of @Column such as [name / column name][unllable / non-empty][length / length]; if there is no @Column, change the camel case name of the field to underscore as the field name, for example: change useName to user_name;

[0125] (6) Convert PO to database table object

[0126] 2. Database scanning

[0127] The database scanning process is as follows Figure 7 As shown, the specific steps are as follows:

[0128] (1) firstly, determining whether the application has a database according to the business application configuration, and if so, parsing the table structure of the application database; that is, in response to the existence of the at least one target data table, obtaining the table structure of the at least one target data table;

[0129] (2) in response to the existence of the at least one target data table, obtaining a database link of any target database

[0130] Get JdbcTemplate first. If there is no JdbcTemplate, get DataSource. If there is no DataSource, create a jdbc link by configuring the database.

[0131] (3) Obtain the table structure and obtain the strategy based on the database type of the current application

[0132] For any target data table in at least one target data table, determine the database type of the database where any target data table is located; obtain a target column information query code that matches the database type of the database where any target data table is located from multiple candidate column information query codes; execute the target column information query code to obtain the table structure of any target data table.

[0133] For example, if the database type is MySQL8: execute the target column information query code "INFORMATION_SCHEMA.COLUMNS" to obtain detailed information about the columns of all tables in the database, including: column name, name of the table to which it belongs, data type, whether NULL value is allowed, default value, etc.;

[0134] If the database type is Oracle, execute the target column information query code "ALL_TAB_COLUMNS" to obtain the table structure information. The table structure information includes the column information of all tables in the database, including column name, data type, length, and whether it can be NULL, etc.

[0135] If the database type is SQL Server, execute the target column information query code "INFORMATION_SCHEMA.COLUMNS" to obtain detailed information about the columns of all tables in the database, including: column name, name of the table to which it belongs, data type, whether NULL values ​​are allowed, default value, etc. Obtain database table information by reading the table information.

[0136] (4) Database table unified object: convert the table objects of MySQL, Oracle, SQL Server and other databases into a unified table object, which is independent of the specific database type;

[0137] (5) Storing unified database table objects: storing unified database table objects and providing a unified visual query page to manage all database tables and trace historical versions of the database.

[0138] 3. Compare the field information of any persistent object with at least one table structure to generate and display the difference information between the field information of any persistent object and at least one table structure

[0139] As an example, compare the database table object converted by PO with the table structure of the database to find the difference between PO and the database.

[0140] Corresponding to the data comparison method provided in the above embodiment, the present disclosure also provides a data comparison device. Since the data comparison device provided in the embodiment of the present disclosure corresponds to the data comparison method provided in the above embodiment, the implementation method of the data comparison method is also applicable to the data comparison device provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.

[0141] Figure 8 It is a structural schematic diagram of a data comparison device shown in the sixth embodiment of the present disclosure.

[0142] like Figure 8 As shown, the data comparison device 800 includes: a first acquisition module 810 , a first judgment module 820 , a second judgment module 830 , a second acquisition module 840 and a comparison module 850 .

[0143] Among them, the first acquisition module 810 is used to obtain the data table mapping information and field information of the at least one persistent object in response to the existence of at least one persistent object in the target business application; the first judgment module 820 is used to judge whether there is at least one target database based on the system configuration information, wherein the target database is used for data storage in the target business application; the second judgment module 830 is used to judge whether there is at least one target data table matching the data table mapping information of any persistent object in the at least one target database based on the data table mapping information of any persistent object in response to the existence of at least one target database; the second acquisition module 840 is used to obtain the table structure of the at least one target data table in response to the existence of at least one target data table; the comparison module 850 is used to compare the field information of any persistent object with the at least one table structure to generate and display the difference information between the field information of any persistent object and the at least one table structure.

[0144] As a possible implementation method of the embodiment of the present disclosure, the second acquisition module 840 is used to determine, for any target data table among the at least one target data table, the database type of the database where the any target data table is located; obtain, from multiple candidate column information query codes, a target column information query code that matches the database type of the database where the any target data table is located; and execute the target column information query code to obtain the table structure of any target data table.

[0145] As a possible implementation method of the embodiment of the present disclosure, the first acquisition module 810 is used to, in response to the existence of at least one persistent object in the target business application, perform reflection parsing on the mapping annotation information of any persistent object to obtain the data table mapping information of any persistent object; perform reflection parsing on the parent class of any persistent object to obtain the basic fields of any persistent object; perform reflection parsing on the subclass of any persistent object to obtain the business fields of any persistent object; and determine the field information of any persistent object based on the basic fields and business fields of any persistent object.

[0146] As a possible implementation method of the embodiment of the present disclosure, the first acquisition module 810 is used to traverse the basic fields and business fields in sequence, and obtain the attribute annotation information of the currently traversed field according to the currently traversed field; parse the attribute annotation information to determine whether the attribute annotation information includes the column information annotation; in response to the attribute annotation information including the column information annotation, reflectively parse the column information annotation to obtain the mapping field and attribute information of the currently traversed field; wherein the mapping field is used to indicate the display format of the currently traversed field in the corresponding data table; determine the field information of any persistent object according to the mapping field and attribute information of the basic field of any persistent object and the attribute information of the business field.

[0147] As a possible implementation method of the embodiment of the present disclosure, the first acquisition module 810 is also used to obtain, in response to the fact that the attribute annotation information does not include the column information annotation, a reference field that matches the currently traversed field; perform format conversion on the currently traversed field according to the reference field that matches the currently traversed field to obtain a mapping field of the currently traversed field; and determine the field information of any persistent object according to the mapping field of the basic field of any persistent object and the mapping field of the business field.

[0148] As a possible implementation method of the embodiment of the present disclosure, the second judgment module 830 is used to obtain a database link of any target database in response to the existence of at least one target database; for any persistent object, based on the data table mapping information of any persistent object, determine whether there is at least one target data table in any target database under the database link.

[0149] As a possible implementation method of the embodiment of the present disclosure, the second judgment module 830 is used to determine whether there is a data access template in the configuration container associated with the target business application in response to the existence of at least one target database; in response to the existence of the data access template, obtain the database link of any target database according to the data access template.

[0150] As a possible implementation method of the embodiment of the present disclosure, the second judgment module 830 is also used to determine whether there is a data source associated with the target business application in response to the absence of a data access template; in response to the existence of a data source, obtain a database link of any target database from the data source; in response to the absence of a data source, create a database link of any target database based on configuration information associated with any target database.

[0151] As a possible implementation of the embodiment of the present disclosure, the data comparison device 800 further includes: a processing module.

[0152] Among them, the processing module is used to insert column information matching the target field information in at least one target data table in response to the difference information indicating that the target field information exists in the field information; wherein the target field information does not match at least one table structure; in response to the difference information indicating that the target column information exists in at least one table structure, delete the target column information in at least one target data table; wherein the target column information does not match the field information.

[0153] The data comparison device of the disclosed embodiment determines whether there is a target database for storing data of the target business application, and when there is at least one target database, determines whether there is a target data table in the at least one target database that matches the data mapping information of any persistent object of the target business application, and if so, compares the field information of any persistent object with the corresponding at least one table structure to obtain difference information between the field information of any persistent object and the at least one table structure, so that unused data columns in the database can be accurately and timely determined based on the difference information, so as to avoid waste of database resources and performance degradation caused by unused data columns (such as redundant data columns).

[0154] In an exemplary embodiment, an electronic device is also provided.

[0155] Among them, electronic equipment includes:

[0156] processor;

[0157] a memory for storing processor-executable instructions;

[0158] The processor is configured to execute instructions to implement the data comparison method proposed in any of the aforementioned embodiments.

[0159] As an example, Fig. 9 is a schematic diagram of the structure of an electronic device 900 shown in an exemplary embodiment of the present disclosure, such as Fig. 9 As shown, the electronic device 900 may further include:

[0160] The memory 910 and the processor 920, a bus 930 connecting different components (including the memory 910 and the processor 920), the memory 910 stores a computer program, and when the processor 920 executes the program, the data comparison method described in the embodiment of the present disclosure is implemented.

[0161] Bus 930 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0162] The electronic device 900 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 900, including volatile and non-volatile media, removable and non-removable media.

[0163] The memory 910 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 940 and / or cache memory 950. The server 900 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 960 may be used to read and write non-removable, non-volatile magnetic media ( Fig. 9 not shown, usually called a "hard drive"). Although Fig. 9 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 930 via one or more data medium interfaces. The memory 910 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.

[0164] A program / utility 980 having a set (at least one) of program modules 970 may be stored, for example, in the memory 910, such program modules 970 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 970 generally perform the functions and / or methods of the embodiments described in the present disclosure.

[0165] The electronic device 900 may also communicate with one or more external devices 990 (e.g., keyboard, pointing device, display 991, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 900, and / or communicate with any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 992. In addition, the electronic device 900 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 993. As shown, the network adapter 993 communicates with other modules of the electronic device 900 through a bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0166] The processor 920 executes various functional applications and data processing by running the programs stored in the memory 910 .

[0167] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the data comparison method of the embodiment of the present disclosure, and will not be repeated here.

[0168] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, and the above instructions can be executed by a processor of an electronic device to complete the data comparison method proposed in any of the above embodiments. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0169] In an exemplary embodiment, a computer program product is also provided, including a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the data comparison method proposed in any of the above embodiments is implemented.

[0170] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0171] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A data comparison method, characterized in that: include: In response to at least one persistent object existing in the target business application, obtaining data table mapping information and field information of the at least one persistent object; According to the system configuration information, determining whether there is at least one target database, wherein the target database is used for storing data for the target business application; In response to the existence of at least one target database, for any persistent object among the at least one persistent object, judging, according to the data table mapping information of the any persistent object, whether there is at least one target data table in the at least one target database that matches the data table mapping information of the any persistent object; In response to the existence of the at least one target data table, acquiring a table structure of the at least one target data table; The field information of any persistent object is compared with at least one table structure to generate and display difference information between the field information of any persistent object and the at least one table structure.

2. The method according to claim 1, characterized in that In response to the existence of the at least one target data table, acquiring the table structure of the at least one target data table includes: For any target data table among the at least one target data table, determine a database type of a database where the any target data table is located; Acquire, from a plurality of candidate column information query codes, a target column information query code that matches a database type of a database where any target data table is located; The target column information query code is executed to obtain the table structure of any target data table.

3. The method according to claim 1, characterized in that: In response to the existence of at least one persistent object in the target business application, obtaining data table mapping information and field information of the at least one persistent object includes: In response to at least one persistent object existing in the target business application, performing reflection parsing on mapping annotation information of any persistent object to obtain data table mapping information of any persistent object; Performing reflection analysis on the parent class of any persistent object to obtain the basic fields of any persistent object; Performing reflection analysis on the subclass where any persistent object is located to obtain the business field of any persistent object; According to the basic fields and business fields of any persistent object, the field information of any persistent object is determined.

4. The method according to claim 3, characterized in that Determining the field information of any persistent object according to the basic field and the business field of any persistent object includes: Traverse the basic fields and business fields in sequence, and obtain the attribute annotation information of the currently traversed field according to the currently traversed field; Parsing the attribute annotation information to determine whether the attribute annotation information includes column information annotation; In response to the column information annotation being included in the attribute annotation information, the column information annotation is reflected and parsed to obtain a mapping field and attribute information of the currently traversed field; wherein the mapping field is used to indicate a display format of the currently traversed field in a corresponding data table; The field information of any persistent object is determined according to the mapping fields and attribute information of the basic fields of any persistent object and the attribute information of the business field.

5. The method according to claim 4, characterized in that The method further comprises: In response to the attribute annotation information not including the column information annotation, acquiring, for the currently traversed field, a reference field matching the currently traversed field; According to a reference field matching the currently traversed field, format conversion is performed on the currently traversed field to obtain a mapping field of the currently traversed field; The field information of any persistent object is determined according to the mapping fields of the basic fields of any persistent object and the mapping fields of the business fields.

6. The method according to claim 1, characterized in that In response to the existence of at least one target database, for any persistent object among the at least one persistent object, judging, according to the data table mapping information of the any persistent object, whether there is at least one target data table in the at least one target database that matches the data table mapping information of the any persistent object, comprises: In response to the existence of at least one target database, obtaining a database link of any target database; For any persistent object, it is determined whether the at least one target data table exists in any target database under the database link according to the data table mapping information of the any persistent object.

7. The method according to claim 6, characterized in that In response to the existence of at least one target database, obtaining a database link of any target database includes: In response to the existence of at least one target database, determining whether a data access template exists in a configuration container associated with the target business application; In response to the existence of the data access template, a database link of any target database is acquired according to the data access template.

8. The method according to claim 7, characterized in that The method further comprises: In response to the data access template not existing, determining whether there is a data source associated with the target business application; In response to the existence of the data source, obtaining a database link of any target database from the data source; In response to the data source not existing, a database link of any one of the target databases is created according to the configuration information associated with any one of the target databases.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: In response to the difference information indicating that target field information exists in the field information, inserting column information matching the target field information into the at least one target data table; wherein the target field information does not match the at least one table structure; In response to the difference information indicating that target column information exists in the at least one table structure, the target column information is deleted in the at least one target data table; wherein the target column information does not match the field information.

10. A data comparison device, characterized in that: include: A first acquisition module, configured to acquire data table mapping information and field information of at least one persistent object in response to the existence of at least one persistent object in the target business application; A first determination module is used to determine whether there is at least one target database according to the system configuration information, wherein the target database is used for data storage of the target business application; A second judgment module is configured to, in response to the existence of at least one target database, determine, for any persistent object among the at least one persistent object, whether there is at least one target data table in the at least one target database that matches the data table mapping information of the any persistent object according to the data table mapping information of the any persistent object; A second acquisition module, configured to acquire a table structure of the at least one target data table in response to the existence of the at least one target data table; The comparison module is used to compare the field information of any persistent object with at least one table structure to generate and display difference information between the field information of any persistent object and the at least one table structure.