CN116069755A - mapper file processing method and related equipment - Google Patents

mapper file processing method and related equipment Download PDF

Info

Publication number
CN116069755A
CN116069755A CN202211352192.3A CN202211352192A CN116069755A CN 116069755 A CN116069755 A CN 116069755A CN 202211352192 A CN202211352192 A CN 202211352192A CN 116069755 A CN116069755 A CN 116069755A
Authority
CN
China
Prior art keywords
mapper
file
mapper file
database
characters
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211352192.3A
Other languages
Chinese (zh)
Inventor
姚小松
李云嵩
赵晨
李阳
马淑静
段利军
侯悦
欧清海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zhongdian Feihua Communication Co Ltd
Original Assignee
Beijing Zhongdian Feihua Communication Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zhongdian Feihua Communication Co Ltd filed Critical Beijing Zhongdian Feihua Communication Co Ltd
Priority to CN202211352192.3A priority Critical patent/CN116069755A/en
Publication of CN116069755A publication Critical patent/CN116069755A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/214Database migration support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a mapper file processing method and related equipment, comprising: obtaining data information of a database, generating entity classes, a mapper interface and a mapper file according to the data information, performing security check and repair on the mapper file to obtain a security mapper file, and replacing characters in the security mapper file in response to determining that the database is migrated to obtain the security mapper file matched with the migrated database. The method and the device solve the problems that in the current MyBatis framework, a protection mechanism does not exist in the framework, and compatibility of the framework is poor.

Description

mapper file processing method and related equipment
Technical Field
The disclosure relates to the technical field of informationized development, in particular to a mapper file processing method and related equipment.
Background
In the field of informatization development, java developers need to write a large number of SQL sentences and frequently operate the database transactions, so that the java developers cannot concentrate on business logic and have low development efficiency. To solve the above problem of interaction between the informatization system and the database, various related database operation frameworks are developed, and currently, there are hibernate, myBatis types of database operation frameworks which are popular, and MyBatis frameworks have great advantages in terms of flexibility and extensibility compared with hibernates, so more and more developers choose to use MyBatis frameworks in more occasions. However, in the current MyBatis framework, the framework itself does not have a protection mechanism, and the framework itself has poor compatibility.
Disclosure of Invention
Accordingly, an objective of the present disclosure is to provide a mapper file processing method and related device for solving or partially solving the above-mentioned problems.
Based on the above object, a first aspect of the present disclosure provides a mapper file processing method, where the method includes:
acquiring data information of a database;
generating entity classes, a mapper interface and a mapper file according to the data information;
performing security inspection and repair on the mapper file to obtain a security mapper file;
and replacing characters in the mapper file in response to the database migration, so as to obtain the mapper file which is matched with the migrated database.
Optionally, the acquiring data information of the database includes:
acquiring table names of all data tables in a database;
and inquiring the data table according to the table name of the data table to obtain the metadata basic information in the data table.
Optionally, the metadata base information includes: the field name, field type, and field are null.
Optionally, the automatically generating the entity class, the mapper interface and the mapper file according to the data information includes:
storing the metadata basic information into a TableInfo class in the database;
filling the TableInfo class into a template of the entity class and storing under a catalog of the entity class;
creating a basic SQL operation method for the data table in the mapper interface, and storing the basic SQL operation method under a java interface directory;
and obtaining SQL operation sentences in the mapper file according to the basic SQL operation method, and storing the SQL operation sentences under the directory of the mapper file.
Optionally, the performing security check and automatic repair on the mapper file to obtain a security mapper file includes:
traversing the mapper file, and matching risk characters, wherein the risk characters comprise spliced character string characters;
in response to the $character contained in the mapper file, determining to intercept a complete SQL statement containing the $character by a subtroping method;
and replacing the $symbol with a # symbol to obtain a secure mapper file, and recording modification information of the mapper file.
Optionally, the method further comprises:
in response to determining that the complete SQL statement contains a special function, performing special processing according to the special function;
determining to add a foreach function in the complete SQL statement and replacing the $symbol with a # symbol in response to the special function being an in function;
determining to add a concat function in the complete SQL statement and replacing the $symbol with a # symbol in response to the special function being a like function;
and responding to the special function as an order by function, and determining to send the complete SQL statement to a user side for checking.
Optionally, in response to determining that the database is migrated, replacing characters in the mapper file to obtain a mapper file adapted to the migrated database, including:
traversing the mapper file to obtain characteristic characters;
analyzing and replacing the characteristic characters to obtain a security mapper file which is matched with the migrated database;
and recording the modification information of the security mapper file.
Based on the same inventive concept, a second aspect of the present disclosure proposes a mapper file processing system, including:
the code generation module is configured to acquire data information of a database, and generate entity classes, a mapper interface and a mapper file according to the data information;
the code safety protection module is configured to perform safety inspection and repair on the mapper file to obtain a safety mapper file;
and the database adaptation module is configured to replace characters in the secure mapper file to obtain a mapper file adapted to the migrated database.
Based on the same inventive concept, a third aspect of the present disclosure proposes an electronic device comprising a memory, a processor and a computer program stored on the memory and executable by the processor, the processor implementing the method as described above when executing the computer program.
Based on the same inventive concept, a fourth aspect of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method as described above.
From the foregoing, it can be seen that the present disclosure provides a method for processing a mapper file and related device, by obtaining data information of a database, generating an entity class, a mapper interface and a mapper file according to the data information, performing security inspection and repair on the mapper file to obtain a security mapper file, and in response to determining that the database is migrated, replacing characters in the security mapper file to obtain a security mapper file adapted to the migrated database. Based on the scheme of the embodiment of the disclosure, the safety risk of development is reduced and the code safety of the java system operation database is improved by carrying out safety check and repair on the mapper file; when the database is migrated, characters in the mapper file are checked and replaced, so that the problems of poor compatibility of the framework and low accuracy of the framework when a user manually modifies the framework are solved, the compatibility of the system is improved, and the workload of the database migration is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the present disclosure or related art, the drawings required for the embodiments or related art description will be briefly described below, and it is apparent that the drawings in the following description are only embodiments of the present disclosure, and other drawings may be obtained according to these drawings without inventive effort to those of ordinary skill in the art.
FIG. 1 is a flowchart of a mapper file processing method according to an embodiment of the disclosure;
FIG. 2A is a first partial flow chart of an embodiment in another application scenario of the present disclosure;
FIG. 2B is a second partial flow chart of an embodiment of another application scenario of the present disclosure;
FIG. 2C is a third partial flow chart of an embodiment in another application scenario of the present disclosure;
FIG. 3 is a block diagram of a mapper file handling system according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
Detailed Description
For the purposes of promoting an understanding of the principles and advantages of the disclosure, reference will now be made to the embodiments illustrated in the drawings and specific language will be used to describe the same.
It should be noted that unless otherwise defined, technical or scientific terms used in the embodiments of the present disclosure should be given the ordinary meaning as understood by one of ordinary skill in the art to which the present disclosure pertains. The terms "first," "second," and the like, as used in embodiments of the present disclosure, do not denote any order, quantity, or importance, but rather are used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that elements or items preceding the word are included in the element or item listed after the word and equivalents thereof, but does not exclude other elements or items. The terms "connected" or "connected," and the like, are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", etc. are used merely to indicate relative positional relationships, which may also be changed when the absolute position of the object to be described is changed.
As described above, in the current map file processing method based on MyBatis framework, the framework itself does not have a protection mechanism, and the framework itself has poor compatibility, so that the accuracy is low when the user manually modifies the framework.
The terms involved in this disclosure are explained as follows:
MyBatis framework: myBatis is an excellent persistence layer framework that supports common SQL queries, stored procedures, and high-level mappings. MyBatis eliminates almost all manual setting of JDBC codes and parameters and retrieval of result sets.
mapper: the mapper (mapper) is the most important file in MyBatis, which contains a set of SQL statements (e.g., query, add, delete, modify), which are called map statements or map SQL statements.
The mapper file: the mapper mapping file is an xml format configuration file, and is composed of a series of elements having hierarchical relationships.
SQL: SQL (Structured Query Language) is a database language with multiple functions such as data manipulation and data definition, and the language has the characteristic of interactivity, so that great convenience can be provided for users, and the database management system should make full use of the SQL language to improve the working quality and efficiency of the computer application system.
Oracle: oracle Database, also known as Oracle RDBMS, or Oracle for short. The system has good portability, convenient use and strong function, and is suitable for various large, medium and small microcomputer environments. The method is an efficient, reliable and high-throughput-adaptive database scheme.
MySQL: mySQL is a relational database management system that keeps data in different tables rather than placing all data in one large warehouse, which increases speed and flexibility.
Based on the above description, this embodiment proposes a mapper file processing method, as shown in fig. 1, where the method includes:
step 101, obtaining data information of a database.
When the method is implemented, the database is connected under the conditions that the design of the database is completed and the construction of the table in the database is completed, and the data information in the database is obtained.
In some embodiments, the obtaining the data information of the database includes obtaining table names of all data tables in the database; and inquiring the data table according to the table name of the data table to obtain the metadata basic information in the data table.
When the method is implemented, after the database connection is completed, the system performs traversal search from the database to obtain table names of all data tables related to the project, and queries the data tables according to the obtained table names to obtain metadata basic information in the data tables. And searching the database through the table names and acquiring the related information in the table, so that the searching accuracy and the inquiring efficiency can be effectively improved.
In some embodiments, the metadata base information includes a field name, a field type, and whether a field is null.
In the implementation, according to the acquired table names of the data tables related to the items, the data tables are accurately searched, and information about field names, field types and whether fields are empty in the data tables is obtained.
And 102, generating entity classes, a mapper interface and a mapper file according to the data information.
In the implementation, the system acquires data information in the data table, wherein the data information comprises a field name, a field type and information whether a field is empty, and according to the data information, entity classes, related mapper interfaces and a mapper file are generated in the system.
In some embodiments, step 102 comprises:
and 1021, storing the metadata basic information into a TableInfo class in the database.
In specific implementation, the TableInfo class represents information in a database, the data table is queried to obtain metadata basic information in the data table, wherein the metadata basic information comprises information about field names, field types and whether fields are empty, and the metadata basic information is stored in the TableInfo class in the database.
Step 1022, filling the TableInfo class into the template of the entity class, and storing under the directory of the entity class.
In the implementation, after the basic metadata information is received and stored in the TableInfo class, the TableInfo class is filled in a template of an entity class generated according to the data information, and the entity class template is stored under a catalogue of the entity class for being called by a database.
Step 1023, creating a basic SQL operation method for the data table in the mapper interface, and storing the basic SQL operation method under a java interface directory.
In specific implementation, a mapper interface is generated according to the data information in the database, a basic SQL operation method for the data table is created in the mapper interface, for example, a modification operation method, a deletion operation method, an insertion operation method and the like for the data table are created, and the basic SQL operation method is stored under a java interface directory.
Step 1024, obtaining an SQL operation statement in the mapper file according to the basic SQL operation method, and storing the SQL operation statement in a directory of the mapper file.
In the implementation, a mapper file is generated according to the data information in the database, in the mapper file, according to the basic SQL operation method of the data table obtained in step 1023, a corresponding basic SQL operation statement is obtained, for example, a modification operation statement, a deletion operation statement, an insertion operation statement, etc. for the data table, and the obtained basic SQL operation statement is stored under the directory of the mapper file.
And 103, performing security check and repair on the mapper file to obtain a security mapper file.
In the specific implementation, in the mapper file, part of basic SQL sentences are automatically generated by a processor, most SQL operation sentences are written by a user, and after the writing is completed, the system performs security check and repair on the mapper file, so that the accuracy of codes can be effectively improved, and the security of the system is enhanced.
In some embodiments, step 103 specifically includes:
step 1031, traversing the mapper file, and matching risk characters, wherein the risk characters comprise spliced character string characters $.
And in the implementation process, traversing inquiry is carried out on the mapper file, and searching and matching of risk characters are carried out, wherein the risk characters comprise spliced character string characters.
Step 1032, in response to the $character being included in the mapper file, determining to intercept a complete SQL statement containing the $character by a subtroping method.
When the query result contains $characters, the complete SQL sentence containing the $characters is obtained by intercepting the substring method.
Step 1033, replacing the $symbol with a # symbol to obtain a secure mapper file, and recording modification information of the mapper file.
When the query in the mapper file contains $symbols, intercepting a complete SQL sentence containing $characters by a subtroping method, changing the spliced character string characters $in the complete SQL sentence into precompiled characters#, and obtaining a changed SQL sentence, wherein the mapper file containing the changed SQL sentence is a safe mapper file. And recording the modification performed by the mapper file to obtain modification information, wherein the modification information comprises performed operations, complete SQL sentences before modification, complete SQL sentences after modification and the like.
In some embodiments, step 103 further comprises:
step 103A, in response to determining that the complete SQL statement contains a special function, performing special processing according to the special function.
When the mapper file is queried to contain $symbols, after a complete SQL sentence containing $symbols is intercepted by a subtroping method, judging whether the complete SQL sentence contains a special function or not, and if so, performing special processing. Wherein the special function comprises at least one of: in function, like function, order by function.
Step 103B, in response to the special function being an in function, determining to add a foreach function to the complete SQL statement, and replacing the $symbol with a # symbol.
When the special function is an in function, adding related sentences of a foreach function in the complete SQL sentence, and simultaneously changing the spliced character string character $in the complete SQL sentence into a precompiled character#.
For example, the complete SQL statement containing the $character intercepted by the subtroping method is select from simCard where name in ($ { names }), at this time, a foreach function is added in the SQL statement, the $symbol is replaced by a # symbol, the modified complete SQL statement is select from simCard where name in < foreach collection = "names" item= "name" open= "(" selector= "," close= ")" > (# { names }) </foreach >, at this time, the precompiled character # can play a role of safety protection, and the safety of the system is improved.
Step 103C, in response to the special function being a like function, determining to add a concat function to the complete SQL statement, and replacing the $symbol with a # symbol.
When the special function is a like function, adding related sentences of a concat function in the complete SQL sentence, and simultaneously changing the spliced character string character $in the complete SQL sentence into a precompiled character#.
For example, the complete SQL statement containing the $character intercepted by the subtroping method is select from simCards where name like '% $ { name }', at this time, a concat is inserted into the complete SQL statement and the SQL statement is spliced again, the $symbol is replaced by a # symbol, the modified complete SQL statement is select from simCards where name like concat ('%', # { name }, '%'), at this time, the pre-compiled character # can play a role in safety protection, and the safety of the system is improved.
And step 103D, responding to the special function as an order by function, and determining to send the complete SQL sentence to a user side for checking.
When the special function is an order by function, the order by function is used for sorting, the sorting is invalid due to the fact that the $symbol is replaced by the # symbol, at the moment, the processor performs red marking processing, informs a user whether the parameters quoted after the order by function is checked are processed, and provides relevant processing examples. The function of the example code is equivalent to that a white list is established in the system, the input parameters are limited, the $character can be used because the parameters are controllable, and the processor only reminds and gives a reference example because the specific definition of the white list is related to the system service, and the specific implementation mode needs to be checked by a user according to the actual service and processed by combining the actual condition.
For example, the complete SQL statement containing the $character intercepted by the subtroping method is selected from simCardAlarm for alarmList order by $ { alarmtm } $ { orderMode }, the first parameter is the alarm time alarmtm, and the first parameter is defined as the initial time and the update time, that is, the rawTime and the update time, and the ordering mode of the latter parameter orderMode is only two types of "asc" and "desc". Marking the complete SQL sentence to be red, notifying a user to check, and giving example codes as follows:
Figure BDA0003919337860000091
and 104, replacing characters in the mapper file in response to the determination of the database migration, so as to obtain the mapper file which is adapted to the migrated database.
In particular, database migration is frequent during software system construction, such as for cloud-up or other reasons. For different databases, partial writing methods in the mapper file are different, and by searching and replacing characters in the mapper file, the workload of manual modification of a user can be reduced, and the accuracy of modification is improved.
In some embodiments, taking the Oracle to MySQL database as an example, step 104 specifically includes:
step 1041, traversing the mapper file to obtain a feature character.
In specific implementation, traversing query is carried out on the current mapper file, and Oracle characteristic characters are matched.
And step 1042, performing analysis and replacement on the characteristic characters to obtain a mapper file which is matched with the migrated database.
In specific implementation, the matched Oracle feature characters are analyzed, and corresponding processing is carried out according to different types, wherein the types comprise data types, function types and the like. And obtaining a mapper file which is matched with the migrated database MySQL according to the processing result.
For example, the data type is Number type, analyzing the Number of parameters carried by the data type, if the Number of parameters is 1, replacing the Number type with the int type; and if the Number of the parameters is 2, replacing the Number type with a decimal type. For the var 'char of MySQL corresponding to Varchar2 of Oracle in the data type, datetime in MySQL corresponding to Datetime in Oracle's Date type, etc., can be directly replaced.
For another example, the function type aspect, such as decode function, trank function, to_char function, etc., needs to intercept the whole SQL statement for parsing, and extracts the parameters to assemble into the case then function of MySQL. The function type can be directly replaced by a function type in which length (str) in Oracle corresponds to char_length (str) of MySQL, and the like.
Step 1043, recording the modification information of the mapper file.
In particular, for modification of the mapper file due to database conversion, modification information of the mapper file needs to be recorded, where the modification information includes a file name, a modification location, a change of a data type, a modification of a function type, and the like.
In the scheme, the security check and repair are carried out on the mapper file, so that the accuracy of codes is effectively improved, the security of the system is enhanced, and the code security of the java system operation database is ensured; by replacing characters in the mapper file during database migration, the compatibility of the system can be improved, the workload of manual modification of a user during database migration can be reduced, and the accuracy of modification can be improved.
Based on the same inventive concept, another embodiment of the present disclosure in an application scenario includes:
step 201, obtaining data information of a database, and generating entity class, a mapper interface and a mapper file according to the data information.
In implementation, as shown in fig. 2A, a database is first connected, a link is created, and data information of a data table in the database is acquired through metaData of the link connection. And assembling file content information into a memory, wherein the file content information comprises a mapper interface content and a mapper file content. Creating a new file, writing the assembled content into the created file, and storing the file into a corresponding directory.
And 202, performing security check and repair on the mapper file.
In implementation, as shown in fig. 2B, the mapper file is traversed and queried, and risk characters are obtained by matching. And analyzing the risk character, and intercepting the complete SQL sentence of the position. Judging whether a special function exists in the intercepted complete SQL statement, and if so, repairing the defect according to the corresponding special function, wherein the special function comprises at least one of the following steps: in function, like function, order by function; if no special function exists, the risk character is replaced by a safe parameter symbol.
And step 203, in response to determining that the database is migrated, performing adaptation replacement on the mapper file.
In the implementation, as shown in fig. 2C, taking an Oracle-to-MySQL database as an example, the mapper file is traversed and queried to match with Oracle feature characters. Dividing the feature characters, if the Oracle feature characters are Oracle feature function names, transferring to a corresponding function processing method for processing, extracting parameters of the SQL sentences, rearranging and replacing the SQL sentences according to MySQL function rules, and recording modified file information including file names, changing positions and the like. If the character is the characteristic character of the non-functional body, replacing the character with MySQL rule, and recording modification information.
It should be noted that the method of the embodiments of the present disclosure may be performed by a single device, such as a computer or a server. The method of the embodiment can also be applied to a distributed scene, and is completed by mutually matching a plurality of devices. In the case of such a distributed scenario, one of the devices may perform only one or more steps of the methods of embodiments of the present disclosure, the devices interacting with each other to accomplish the methods.
It should be noted that the foregoing describes some embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments described above and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Based on the same inventive concept, the disclosure also provides a mapper file processing system corresponding to the method of any embodiment.
Referring to fig. 3, fig. 3 is a mapper file processing system according to an embodiment, including:
the code generating module 301 is configured to obtain data information of a database, and generate entity classes, a mapper interface and a mapper file according to the data information;
the code security protection module 302 is configured to perform security inspection and repair on the mapper file to obtain a security mapper file;
and the database adapting module 303 is configured to replace characters in the mapper file to obtain a mapper file adapted to the migrated database.
In some embodiments, the code auto-generation module 301 specifically includes:
the information acquisition processing unit is configured to acquire table names of all data tables in a database, and inquire the data tables according to the table names of the data tables to obtain metadata basic information in the data tables.
A data storage processing unit configured to store the metadata basic information into a TableInfo class in the database; filling the TableInfo class into a template of the entity class and storing under a catalog of the entity class; creating a basic SQL operation method for the data table in the mapper interface, and storing the basic SQL operation method under a java interface directory; and obtaining SQL operation sentences in the mapper file according to the basic SQL operation method, and storing the SQL operation sentences under the directory of the mapper file.
In some embodiments, code security module 302 specifically includes:
the traversal matching unit is configured to traverse the mapper file and match risk characters, wherein the risk characters comprise spliced character string characters.
And the statement intercepting unit is configured to determine to intercept a complete SQL statement containing the $character by a subtroping method in response to the $character contained in the mapper file.
And the replacement recording unit is configured to replace the $symbol with a # symbol, obtain a secure mapper file, and record modification information of the mapper file.
And the special processing unit is configured to perform special processing according to the special function in response to determining that the complete SQL statement contains the special function.
In some embodiments, the database adaptation module 303 specifically includes:
and the traversing query unit is configured to perform traversing query on the mapper file to obtain characteristic characters.
And the analysis and replacement unit is configured to analyze and replace the characteristic characters to obtain a security mapper file which is matched with the migrated database.
And an information recording unit configured to record modification information of the mapper file.
For convenience of description, the above devices are described as being functionally divided into various modules, respectively. Of course, the functions of the various modules may be implemented in the same one or more pieces of software and/or hardware when implementing the present disclosure.
The device of the foregoing embodiment is configured to implement the corresponding mapper file processing method in any one of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Based on the same inventive concept, the present disclosure also provides an electronic device corresponding to the method of any embodiment, including a memory, a processor, and a computer program stored on the memory and capable of running on the processor, where the processor implements the mapper file processing method of any embodiment when executing the program.
Fig. 4 shows a more specific hardware architecture of an electronic device according to this embodiment, where the device may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 implement communication connections therebetween within the device via a bus 1050.
The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit ), microprocessor, application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc. for executing relevant programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory ), static storage device, dynamic storage device, or the like. Memory 1020 may store an operating system and other application programs, and when the embodiments of the present specification are implemented in software or firmware, the associated program code is stored in memory 1020 and executed by processor 1010.
The input/output interface 1030 is used to connect with an input/output module for inputting and outputting information. The input/output module may be configured as a component in a device (not shown) or may be external to the device to provide corresponding functionality. Wherein the input devices may include a keyboard, mouse, touch screen, microphone, various types of sensors, etc., and the output devices may include a display, speaker, vibrator, indicator lights, etc.
Communication interface 1040 is used to connect communication modules (not shown) to enable communication interactions of the present device with other devices. The communication module may implement communication through a wired manner (such as USB, network cable, etc.), or may implement communication through a wireless manner (such as mobile network, WIFI, bluetooth, etc.).
Bus 1050 includes a path for transferring information between components of the device (e.g., processor 1010, memory 1020, input/output interface 1030, and communication interface 1040).
It should be noted that although the above-described device only shows processor 1010, memory 1020, input/output interface 1030, communication interface 1040, and bus 1050, in an implementation, the device may include other components necessary to achieve proper operation. Furthermore, it will be understood by those skilled in the art that the above-described apparatus may include only the components necessary to implement the embodiments of the present description, and not all the components shown in the drawings.
The electronic device of the foregoing embodiment is configured to implement the corresponding mapper file processing method in any one of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which is not described herein again.
Based on the same inventive concept, corresponding to any of the above embodiments of the method, the present disclosure further provides a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the mapper file processing method according to any one of the above embodiments.
The computer readable media of the present embodiments, including both permanent and non-permanent, removable and non-removable media, may be used to implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device.
The storage medium of the foregoing embodiment stores computer instructions for causing the computer to execute the mapper file processing method according to any one of the foregoing embodiments, and has the advantages of the corresponding method embodiments, which are not described herein.
Those of ordinary skill in the art will appreciate that: the discussion of any of the embodiments above is merely exemplary and is not intended to suggest that the scope of the disclosure, including the claims, is limited to these examples; the technical features of the above embodiments or in the different embodiments may also be combined under the idea of the present disclosure, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present disclosure as described above, which are not provided in details for the sake of brevity.
Additionally, well-known power/ground connections to Integrated Circuit (IC) chips and other components may or may not be shown within the provided figures, in order to simplify the illustration and discussion, and so as not to obscure the embodiments of the present disclosure. Furthermore, the devices may be shown in block diagram form in order to avoid obscuring the embodiments of the present disclosure, and this also accounts for the fact that specifics with respect to implementation of such block diagram devices are highly dependent upon the platform on which the embodiments of the present disclosure are to be implemented (i.e., such specifics should be well within purview of one skilled in the art). Where specific details (e.g., circuits) are set forth in order to describe example embodiments of the disclosure, it should be apparent to one skilled in the art that embodiments of the disclosure can be practiced without, or with variation of, these specific details. Accordingly, the description is to be regarded as illustrative in nature and not as restrictive.
While the present disclosure has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of those embodiments will be apparent to those skilled in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
The disclosed embodiments are intended to embrace all such alternatives, modifications and variances which fall within the broad scope of the appended claims. Accordingly, any omissions, modifications, equivalents, improvements, and the like, which are within the spirit and principles of the embodiments of the disclosure, are intended to be included within the scope of the disclosure.

Claims (10)

1. The mapper file processing method is characterized by comprising the following steps:
acquiring data information of a database;
generating entity classes, a mapper interface and a mapper file according to the data information;
performing security inspection and repair on the mapper file to obtain a security mapper file;
and replacing characters in the mapper file in response to the database migration, so as to obtain the mapper file which is matched with the migrated database.
2. The method of claim 1, wherein the obtaining data information of the database comprises:
acquiring table names of all data tables in a database;
and inquiring the data table according to the table name of the data table to obtain the metadata basic information in the data table.
3. The method of claim 2, wherein the metadata base information comprises: the field name, field type, and field are null.
4. The method according to claim 2, wherein the automatically generating entity class and a mapper interface and a mapper file according to the data information comprises:
storing the metadata basic information into a TableInfo class in the database;
filling the TableInfo class into a template of the entity class and storing under a catalog of the entity class;
creating a basic SQL operation method for the data table in the mapper interface, and storing the basic SQL operation method under a java interface directory;
and obtaining SQL operation sentences in the mapper file according to the basic SQL operation method, and storing the SQL operation sentences under the directory of the mapper file.
5. The method of claim 1, wherein the performing security check and automatic repair on the mapper file to obtain a secure mapper file comprises:
traversing the mapper file, and matching risk characters, wherein the risk characters comprise spliced character string characters;
in response to the $character contained in the mapper file, determining to intercept a complete SQL statement containing the $character by a subtroping method;
and replacing the $symbol with a # symbol to obtain a secure mapper file, and recording modification information of the mapper file.
6. The method as recited in claim 5, further comprising:
in response to determining that the complete SQL statement contains a special function, performing special processing according to the special function;
determining to add a foreach function in the complete SQL statement and replacing the $symbol with a # symbol in response to the special function being an in function;
determining to add a concat function in the complete SQL statement and replacing the $symbol with a # symbol in response to the special function being a like function;
and responding to the special function as an order by function, and determining to send the complete SQL statement to a user side for checking.
7. The method of claim 1, wherein the replacing characters in the mapper file in response to determining that the database is migrated to obtain a mapper file adapted to the migrated database comprises:
traversing the mapper file to obtain characteristic characters;
analyzing and replacing the characteristic characters to obtain a mapper file which is matched with the migrated database;
and recording the modification information of the mapper file.
8. A mapper file handling system, comprising:
the code generation module is configured to acquire data information of a database, and generate entity classes, a mapper interface and a mapper file according to the data information;
the code safety protection module is configured to perform safety inspection and repair on the mapper file to obtain a safety mapper file;
and the database adaptation module is configured to replace characters in the mapper file to obtain the mapper file adapted to the migrated database.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of any one of claims 1 to 7 when the program is executed.
10. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1 to 7.
CN202211352192.3A 2022-10-31 2022-10-31 mapper file processing method and related equipment Pending CN116069755A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211352192.3A CN116069755A (en) 2022-10-31 2022-10-31 mapper file processing method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211352192.3A CN116069755A (en) 2022-10-31 2022-10-31 mapper file processing method and related equipment

Publications (1)

Publication Number Publication Date
CN116069755A true CN116069755A (en) 2023-05-05

Family

ID=86172266

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211352192.3A Pending CN116069755A (en) 2022-10-31 2022-10-31 mapper file processing method and related equipment

Country Status (1)

Country Link
CN (1) CN116069755A (en)

Similar Documents

Publication Publication Date Title
US8959106B2 (en) Class loading using java data cartridges
US8447744B2 (en) Extensibility platform using data cartridges
US8601016B2 (en) Pre-generation of structured query language (SQL) from application programming interface (API) defined query systems
CN107122368B (en) Data verification method and device and electronic equipment
WO2019237333A1 (en) Converting database language statements between dialects
CN106648569B (en) Target serialization realization method and device
CN114356851B (en) Data file storage method and device, electronic equipment and storage medium
CN113448562B (en) Automatic logic code generation method and device and electronic equipment
CN108509199A (en) Method, device, equipment and storage medium for automatically generating Chinese annotations
JP2020119348A (en) Analysis program, analysis method, and analysis device
CN112035443A (en) Big data execution method, system, equipment and storage medium based on Linux platform
CN111508562A (en) Visual display method, device, equipment and medium of flow descriptive language
Ledvinka et al. A comparison of object-triple mapping libraries
CN108008947B (en) Intelligent prompting method and device for programming statement, server and storage medium
EP3816814A1 (en) Crux detection in search definitions
US9201937B2 (en) Rapid provisioning of information for business analytics
CN116069755A (en) mapper file processing method and related equipment
CN115114297A (en) Data lightweight storage and search method and device, electronic equipment and storage medium
CN114791882A (en) Method and device for solving variable naming conflict, electronic equipment and storage medium
CN114281845A (en) Index generation method and device, electronic equipment and readable storage medium
CN113504904A (en) User-defined function implementation method and device, computer equipment and storage medium
CN112883044A (en) Data processing method and device for database and computer readable medium
CN113609128A (en) Method and device for generating database entity class, terminal equipment and storage medium
Matter Big data analytics: a guide to data science practitioners making the transition to big data
US20240193135A1 (en) Systems, methods, and media for accessing derivative properties from a post relational database utilizing a logical schema instruction that includes a base object identifier

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination