CN113609128A - Method and device for generating database entity class, terminal equipment and storage medium - Google Patents
Method and device for generating database entity class, terminal equipment and storage medium Download PDFInfo
- Publication number
- CN113609128A CN113609128A CN202110825796.4A CN202110825796A CN113609128A CN 113609128 A CN113609128 A CN 113609128A CN 202110825796 A CN202110825796 A CN 202110825796A CN 113609128 A CN113609128 A CN 113609128A
- Authority
- CN
- China
- Prior art keywords
- database
- generating
- structure information
- table structure
- format file
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 53
- 238000004590 computer program Methods 0.000 claims description 20
- 238000004458 analytical method Methods 0.000 claims description 11
- 230000008569 process Effects 0.000 abstract description 12
- 230000006870 function Effects 0.000 description 11
- 238000010586 diagram Methods 0.000 description 4
- 238000007726 management method Methods 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000006243 chemical reaction Methods 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000007792 addition Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application is applicable to the technical field of computers, and provides a method, a device, terminal equipment and a storage medium for generating database entity classes, wherein the method comprises the following steps: acquiring table structure information of a database; generating a preset format file according to the table structure information; analyzing the preset format file to store the table structure information into a preset structural body; and generating a corresponding database entity class according to the structure body. The database entity class is automatically generated, so that the labor loss in the compiling process is reduced, the corresponding data operation can be directly executed on the database based on the generated entity class, and the generation and management efficiency of the database is improved.
Description
Technical Field
The present application belongs to the field of computer technologies, and in particular, to a method and an apparatus for generating database entity classes, a terminal device, and a storage medium.
Background
Usually, during the programming process, a corresponding database needs to be established for storing corresponding data, wherein a relational database is the most commonly used database type.
However, in the process of establishing the relational database, each data field needs to be mapped to a programming language type one by one, so that corresponding operations of increasing, deleting, checking and modifying the data field value are facilitated.
Disclosure of Invention
The embodiment of the application provides a method, a device, a terminal device and a readable storage medium for generating database entity classes, which can solve the problems that when a relational database is used, writing of data fields consumes a large amount of labor and time and the efficiency is low.
In a first aspect, an embodiment of the present application provides a method for generating a database entity class, including:
acquiring table structure information of a database;
generating a preset format file according to the table structure information;
analyzing the preset format file to store the table structure information into a preset structure body;
and generating a corresponding database entity class according to the structural body.
In one embodiment, the obtaining table structure information of the database includes:
acquiring all database tables in the database;
acquiring table structure information of each database table; wherein the table structure information includes a table name, a table name code, a table annotation, and field information in a database table.
In one embodiment, the generating a preset format file according to the table structure information includes:
determining the type of the database;
and adopting a corresponding functional module according to the type of the database, and converting the table structure information of the database into a corresponding preset format file.
In one embodiment, the obtaining the table structure information of each database table includes:
and acquiring the table structure information of each database table by using SQL sentences.
In one embodiment, the parsing the preset format file to store the table structure information in a preset structure includes:
generating a corresponding structural body based on each database table in advance;
analyzing the preset format file to obtain the table structure information of each database table;
and storing the table structure information of each database table obtained by analysis into a corresponding structural body.
In one embodiment, the generating a corresponding database entity class according to the structure includes:
determining the type of the field in each database table based on the structure;
and generating an entity class corresponding to each database table according to the type of the field.
In one embodiment, after the generating the corresponding database entity class according to the structure, the method further includes:
and generating a corresponding base class according to all the entity classes.
In a second aspect, an embodiment of the present application provides an apparatus for generating a database entity class, including:
the acquisition module is used for acquiring the table structure information of the database;
the first generating module is used for generating a preset format file according to the table structure information;
the analysis module is used for analyzing the preset format file so as to store the table structure information into a preset structural body;
and the second generation module is used for generating a corresponding database entity class according to the structural body.
In one embodiment, the obtaining module includes:
the first acquisition unit is used for acquiring all database tables in the database;
a second obtaining unit configured to obtain table structure information of each database table; wherein the table structure information includes a table name, a table name code, a table annotation, and field information in a database table.
In one embodiment, the first generating module includes:
a third determining unit, configured to determine a type of the database;
and the conversion unit is used for adopting a corresponding functional module according to the type of the database and converting the table structure information of the database into a corresponding preset format file.
In one embodiment, the parsing module includes:
a first generation unit configured to generate a corresponding structure in advance based on each database table;
the analysis unit is used for analyzing the preset format file to obtain the table structure information of each database table;
and the storage unit is used for storing the table structure information of each database table obtained by analysis into the corresponding structural body.
In an embodiment, the second obtaining unit is specifically configured to obtain the table structure information of each database table by using an SQL statement.
In one embodiment, the second generating module includes:
a fourth determining unit, configured to determine the type of the field in each database table based on the structure;
and the second generation unit is used for generating an entity class corresponding to each database table according to the type of the field.
In one embodiment, the apparatus further comprises:
and the third generation module is used for generating a corresponding base class according to all the entity classes.
In a third aspect, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor, when executing the computer program, implements the method for generating a database entity class as described in any one of the above first aspects.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the method for generating a database entity class according to any one of the first aspect is implemented.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on a terminal device, causes the terminal device to execute the method for generating a database entity class according to any one of the above first aspects.
Compared with the prior art, the embodiment of the application has the advantages that: the database entity class is automatically generated, so that the labor loss in the compiling process is reduced, the corresponding data operation can be directly executed on the database based on the generated entity class, and the generation and management efficiency of the database is improved.
It is understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and are not described herein again.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for generating a database entity class according to an embodiment of the present application;
fig. 2 is a flowchart illustrating a step S101 of a method for generating a database entity class according to an embodiment of the present application;
fig. 3 is a flowchart illustrating a step S102 of a method for generating a database entity class according to an embodiment of the present application;
fig. 4 is a flowchart illustrating step S103 of a method for generating a database entity class according to an embodiment of the present application;
FIG. 5 is a schematic structural diagram of an apparatus for generating a database entity class according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
The method for generating the database entity class provided by the embodiment of the present application may be applied to terminal devices such as a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a Personal Digital Assistant (PDA), and the specific type of the terminal device is not limited in any way in the embodiment of the present application.
Fig. 1 shows a schematic flow chart of a method for generating a database entity class provided by the present application, which can be applied to the above-mentioned notebook computer by way of example and not limitation.
S101, obtaining table structure information of a database;
specifically, when the current device supports multiple relational databases (such as the DB2 database, the oracle database, and the Mysql database), the database type of the target (for example, the database type of the target is set to the Mysql database) is obtained, and the table structure information of each database table in the database of the target.
S102, generating a preset format file according to the table structure information;
specifically, a corresponding preset format file is generated according to the type of the target database and the table structure information of the database table, wherein the preset format file is used for storing the table structure information of the database table. The preset format file specifically refers to an XML format file (specifically, an sql2XML. bin file), and the XML format file is a lightweight data storage file, can be used for performing data exchange, can retain a data structure such as a parent/child relationship, and is more convenient for storing table structure information of a database table.
S103, analyzing the preset format file to store the table structure information into a preset structural body;
specifically, the preset format file is analyzed, the table structure information of the database table is obtained, and the table structure information of the database table is stored into a preset structure body, wherein the preset structure body is used for storing the table structure information in the database table and converting the table structure information into an entity class.
It can be understood that, in order to ensure the accuracy of the entity class, a structure is set to store the table structure information of a database table.
And S104, generating a corresponding database entity class according to the structural body.
Specifically, a corresponding database entity class is determined and generated according to the table structure information in each structure body, and the type of the database field is corresponding to the C + + type. Database operations based on database entity classes include, but are not limited to, operations of writing data, deleting data, updating data, searching data, and the like.
The method for automatically generating the database entity class is provided by generating the preset format file according to the table structure information of the database, storing the table structure information into the preset structure body based on the preset format file, and further generating the corresponding database entity class, so that various database operations are executed on the database according to the automatically generated entity class, and the generation and management efficiency of the database is improved.
As shown in fig. 2, in an embodiment, the obtaining table structure information of the database includes:
s1011, acquiring all database tables in the database;
s1012, acquiring the table structure information of each database table; wherein the table structure information includes a table name, a table name code, a table annotation, and field information in a database table.
Specifically, all database tables contained in the target database are acquired, and corresponding SQL statements are acquired according to the type of the target database to acquire table structure information of each database table. In other embodiments, a dedicated API may be used to look up the table structure information. The table structure information includes, but is not limited to, a table name code, a table annotation, and field information in a database table, and the field information in the database table includes, but is not limited to, a name, a column name code, a column annotation, a column type, a column length, a column default value, whether a column must be filled, a column precision, a column numeric range, whether a column is automatically added, whether a column is an index, whether a column is a primary key, and whether a column is a foreign key.
In one embodiment, the obtaining the table structure information of each database table includes:
and acquiring the table structure information of each database table by using SQL sentences.
For example, the type of the target database is a MySQL database, and SQL statements corresponding to the MySQL database are used to obtain table structure information of each database table in the target database.
As shown in fig. 3, in an embodiment, the generating a preset format file according to the table structure information includes:
s1021, determining the type of the database;
and S1022, adopting a corresponding function module according to the type of the database, and converting the table structure information of the database into a corresponding preset format file.
Specifically, the type of the target database is determined, the corresponding function module is determined according to the type of the target database, and the function module is called by the application program to convert the table structure information of the database into the corresponding preset format file. The function module is used for storing table structure information corresponding to the type of the database of the target. For example, the target database is a DB2 database, the corresponding function module is a DB2 module (sql2xmldatadb2.hpp), the target database is an Oracle database, the corresponding function module is an Oracle module (sql2xmldataoracle. hpp), the target database is a Mysql database, and the corresponding function module is a Mysql module (sql2xmldatamysql. hpp).
As shown in fig. 4, in an embodiment, the parsing the preset format file to store the table structure information in a preset structure includes:
s1031, generating corresponding structural bodies based on each database table in advance;
s1032, analyzing the preset format file to obtain the table structure information of each database table;
and S1033, storing the table structure information of each database table obtained through analysis into a corresponding structural body.
Specifically, one-to-one corresponding structural bodies are generated in advance based on each database table, the preset format file is analyzed to obtain the table structure information of each database table, and the table structure information of each database table obtained through analysis is stored in the corresponding structural body.
In one embodiment, one structure Table _ t stores Table structure information of one database Table, the structure Table _ t includes a structure _ tag _ tables for storing a plurality of columns in the database Table, a vector in the structure _ tag _ tables is used for storing a structure Column _ t representing Column information, and each database Table is respectively placed in the vector to obtain all database tables in the database.
In one embodiment, the generating a corresponding database entity class according to the structure includes:
determining the type of the field in each database table based on the structure;
and generating an entity class corresponding to each database table according to the type of the field.
Specifically, based on the table structure information in the structure body, the type of the field contained in each database table and the data operation (data operation includes operations such as addition, deletion, modification, and lookup) that can be performed on the field are determined, and the entity class corresponding to each database table is generated according to the type of the field contained in each database table.
In one embodiment, the corresponding variable type may be determined according to column information included in table structure information in a preset format file, and thus, an entity class corresponding to the table structure information is determined.
In one embodiment, after the generating the corresponding database entity class according to the structure, the method further includes:
and generating a corresponding base class according to all the entity classes.
Specifically, in order to avoid damaging the database due to unpredictable errors occurring when the database is actually operated in the entity class, a corresponding base class needs to be generated based on all the entity classes; the module for storing the base class in the preset format file is specifically as follows: the entry class of the database module (sql 2xmlmmodule.
In one embodiment, the method further comprises:
and when a database operation instruction is received, corresponding operation is executed on the fields in the entity class based on the database operation instruction.
Specifically, when a database operation instruction is received, corresponding data operations such as adding, deleting, modifying or querying fields in the entity class are executed based on the database operation instruction.
In one embodiment, after the entity class of the target database is created, the value of each field in the database table may be set, the value of the field is written into the database table, and data operations such as adding, querying, updating (i.e., modifying operations), deleting, and the like may be performed on the database table according to user requirements.
According to the embodiment, the entity class of the database is automatically generated, so that the labor loss in the compiling process is reduced, the corresponding data operation can be directly executed on the database based on the generated entity class, and the generation and management efficiency of the database is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Corresponding to the method for generating a database entity class described in the foregoing embodiment, fig. 5 shows a block diagram of an apparatus for generating a database entity class provided in the embodiment of the present application, and for convenience of explanation, only the parts related to the embodiment of the present application are shown.
Referring to fig. 5, the apparatus 100 for generating a database entity class includes:
an obtaining module 101, configured to obtain table structure information of a database;
the first generating module 102 is configured to generate a preset format file according to the table structure information;
the analysis module 103 is configured to analyze the preset format file to store the table structure information into a preset structure;
and a second generating module 104, configured to generate a corresponding database entity class according to the structure.
In one embodiment, the obtaining module includes:
the first acquisition unit is used for acquiring all database tables in the database;
a second obtaining unit configured to obtain table structure information of each database table; wherein the table structure information includes a table name, a table name code, a table annotation, and field information in a database table.
In an embodiment, the second obtaining unit is specifically configured to obtain the table structure information of each database table by using an SQL statement.
In one embodiment, the first generating module includes:
a third determining unit, configured to determine a type of the database;
and the conversion unit is used for adopting a corresponding functional module according to the type of the database and converting the table structure information of the database into a corresponding preset format file.
In one embodiment, the parsing module includes:
a first generation unit configured to generate a corresponding structure in advance based on each database table;
the analysis unit is used for analyzing the preset format file to obtain the table structure information of each database table;
and the storage unit is used for storing the table structure information of each database table obtained by analysis into the corresponding structural body.
In one embodiment, the second generating module includes:
a fourth determining unit, configured to determine the type of the field in each database table based on the structure;
and the second generation unit is used for generating an entity class corresponding to each database table according to the type of the field.
In one embodiment, the apparatus further comprises:
and the third generation module is used for generating a corresponding base class according to all the entity classes.
In one embodiment, the apparatus further comprises:
and the execution module is used for executing corresponding operation on the fields in the entity class based on the database operation instruction when the database operation instruction is received.
According to the embodiment, the entity class of the database is automatically generated, so that the labor loss in the compiling process is reduced, the corresponding data operation can be directly executed on the database based on the generated entity class, and the generation and management efficiency of the database is improved.
It should be noted that, for the information interaction, execution process, and other contents between the above-mentioned devices/units, the specific functions and technical effects thereof are based on the same concept as those of the embodiment of the method of the present application, and specific reference may be made to the part of the embodiment of the method, which is not described herein again.
Fig. 6 is a schematic structural diagram of the terminal device provided in this embodiment. As shown in fig. 6, the terminal device 6 of this embodiment includes: at least one processor 60 (only one shown in fig. 6), a memory 61, and a computer program 62 stored in the memory 61 and executable on the at least one processor 60, wherein the processor 60 executes the computer program 62 to implement the steps in any of the various above-described method embodiments for generating database entity classes.
The terminal device 6 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 60, a memory 61. Those skilled in the art will appreciate that fig. 6 is only an example of the terminal device 6, and does not constitute a limitation to the terminal device 6, and may include more or less components than those shown, or combine some components, or different components, such as an input/output device, a network access device, and the like.
The Processor 60 may be a Central Processing Unit (CPU), and the Processor 60 may be other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 61 may in some embodiments be an internal storage unit of the terminal device 6, such as a hard disk or a memory of the terminal device 6. In other embodiments, the memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital Card (SD), a Flash memory Card (Flash Card), and the like, which are equipped on the terminal device 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the terminal device 6. The memory 61 is used for storing an operating system, an application program, a BootLoader (BootLoader), data, and other programs, such as program codes of the computer program. The memory 61 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps in the above-mentioned method embodiments.
The embodiments of the present application provide a computer program product, which when running on a mobile terminal, enables the mobile terminal to implement the steps in the above method embodiments when executed.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing apparatus/terminal apparatus, a recording medium, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other ways. For example, the above-described apparatus/network device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implementing, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.
Claims (10)
1. A method of generating a class of database entities, comprising:
acquiring table structure information of a database;
generating a preset format file according to the table structure information;
analyzing the preset format file to store the table structure information into a preset structure body;
and generating a corresponding database entity class according to the structural body.
2. The method of generating a class of database entities according to claim 1, wherein said obtaining table structure information of a database comprises:
acquiring all database tables in the database;
acquiring table structure information of each database table; wherein the table structure information includes a table name, a table name code, a table annotation, and field information in a database table.
3. The method of generating database entity classes according to claim 2, wherein said obtaining table structure information for each database table comprises:
and acquiring the table structure information of each database table by using SQL sentences.
4. The method for generating database entity classes according to claim 1, wherein said generating a preset format file according to said table structure information comprises:
determining the type of the database;
and adopting a corresponding functional module according to the type of the database, and converting the table structure information of the database into a corresponding preset format file.
5. The method of claim 1, wherein parsing the pre-formatted file to store the table structure information in a pre-defined structure comprises:
generating a corresponding structural body based on each database table in advance;
analyzing the preset format file to obtain the table structure information of each database table;
and storing the table structure information of each database table obtained by analysis into a corresponding structural body.
6. The method of generating database entity classes according to claim 1, wherein said generating corresponding database entity classes according to said structure body comprises:
determining the type of the field in each database table based on the structure;
and generating an entity class corresponding to each database table according to the type of the field.
7. The method of generating database entity classes according to any of claims 1 to 6, further comprising, after generating the corresponding database entity class according to the structure body:
and generating a corresponding base class according to all the entity classes.
8. An apparatus for generating classes of database entities, comprising:
the acquisition module is used for acquiring the table structure information of the database;
the first generating module is used for generating a preset format file according to the table structure information;
the analysis module is used for analyzing the preset format file so as to store the table structure information into a preset structural body;
and the second generation module is used for generating a corresponding database entity class according to the structural body.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110825796.4A CN113609128B (en) | 2021-07-21 | 2021-07-21 | Method, device, terminal equipment and storage medium for generating database entity class |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110825796.4A CN113609128B (en) | 2021-07-21 | 2021-07-21 | Method, device, terminal equipment and storage medium for generating database entity class |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113609128A true CN113609128A (en) | 2021-11-05 |
CN113609128B CN113609128B (en) | 2024-08-13 |
Family
ID=78305054
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110825796.4A Active CN113609128B (en) | 2021-07-21 | 2021-07-21 | Method, device, terminal equipment and storage medium for generating database entity class |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113609128B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114443647A (en) * | 2021-12-28 | 2022-05-06 | 厦门市美亚柏科信息股份有限公司 | Method and device for processing data and storage medium |
CN115495442A (en) * | 2022-11-16 | 2022-12-20 | 深圳市明源云采购科技有限公司 | Database operation file generation method, device, equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080228800A1 (en) * | 2007-03-13 | 2008-09-18 | Dettinger Richard D | Determining query entities for an abstract database from a physical database table |
CN105278961A (en) * | 2015-10-28 | 2016-01-27 | 广州华多网络科技有限公司 | Method and system for generating database table structure document |
CN105389339A (en) * | 2015-10-20 | 2016-03-09 | 咸亨国际(杭州)物联网信息产业有限公司 | Tool for rapid generation of database sql statement and entity class |
US20180137114A1 (en) * | 2016-11-14 | 2018-05-17 | International Business Machines Corporation | Data migration in a networked computer environment |
WO2018127747A1 (en) * | 2017-01-06 | 2018-07-12 | University Of Florida Research Foundation, Inc. | A method, apparatus and computer program product for user-directed database configuration, and automated mining and conversion of data |
CN108399130A (en) * | 2018-02-28 | 2018-08-14 | 平安科技(深圳)有限公司 | Method, device and equipment for automatically generating test case and readable storage medium |
US10872065B1 (en) * | 2015-08-03 | 2020-12-22 | Intelligence Designs, LLC | System for managing relational databases using XML objects |
CN112711405A (en) * | 2020-12-28 | 2021-04-27 | 山东浪潮通软信息科技有限公司 | Method, equipment and storage medium for generating add-delete-modify-check application program interface |
-
2021
- 2021-07-21 CN CN202110825796.4A patent/CN113609128B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080228800A1 (en) * | 2007-03-13 | 2008-09-18 | Dettinger Richard D | Determining query entities for an abstract database from a physical database table |
US10872065B1 (en) * | 2015-08-03 | 2020-12-22 | Intelligence Designs, LLC | System for managing relational databases using XML objects |
CN105389339A (en) * | 2015-10-20 | 2016-03-09 | 咸亨国际(杭州)物联网信息产业有限公司 | Tool for rapid generation of database sql statement and entity class |
CN105278961A (en) * | 2015-10-28 | 2016-01-27 | 广州华多网络科技有限公司 | Method and system for generating database table structure document |
US20180137114A1 (en) * | 2016-11-14 | 2018-05-17 | International Business Machines Corporation | Data migration in a networked computer environment |
WO2018127747A1 (en) * | 2017-01-06 | 2018-07-12 | University Of Florida Research Foundation, Inc. | A method, apparatus and computer program product for user-directed database configuration, and automated mining and conversion of data |
CN108399130A (en) * | 2018-02-28 | 2018-08-14 | 平安科技(深圳)有限公司 | Method, device and equipment for automatically generating test case and readable storage medium |
CN112711405A (en) * | 2020-12-28 | 2021-04-27 | 山东浪潮通软信息科技有限公司 | Method, equipment and storage medium for generating add-delete-modify-check application program interface |
Non-Patent Citations (1)
Title |
---|
张少应;: "基于实体类的数据库访问技术的研究与实现", 计算机与信息技术, no. 05, 20 May 2009 (2009-05-20) * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114443647A (en) * | 2021-12-28 | 2022-05-06 | 厦门市美亚柏科信息股份有限公司 | Method and device for processing data and storage medium |
CN115495442A (en) * | 2022-11-16 | 2022-12-20 | 深圳市明源云采购科技有限公司 | Database operation file generation method, device, equipment and storage medium |
CN115495442B (en) * | 2022-11-16 | 2023-08-04 | 深圳市明源云采购科技有限公司 | Database operation file generation method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN113609128B (en) | 2024-08-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110795455B (en) | Dependency analysis method, electronic device, computer apparatus, and readable storage medium | |
CN110633292A (en) | Query method, device, medium, equipment and system for heterogeneous database | |
CN108334609B (en) | Method, device, equipment and storage medium for realizing JSON format data access in Oracle | |
CN110704398A (en) | Database migration method and device from MySQL to Oracle and computer equipment | |
CN110334109B (en) | Relational database data query method, system, medium and electronic device | |
MX2013014800A (en) | Recommending data enrichments. | |
CN110688544A (en) | Method, device and storage medium for querying database | |
CN113419740B (en) | Program data stream analysis method and device, electronic equipment and readable storage medium | |
CN112068874A (en) | Software project continuous integration method and device, terminal equipment and storage medium | |
CN113609128B (en) | Method, device, terminal equipment and storage medium for generating database entity class | |
CN113268500B (en) | Service processing method and device and electronic equipment | |
CN111104426A (en) | Data query method and system | |
CN109471893B (en) | Network data query method, equipment and computer readable storage medium | |
CN116244387A (en) | Entity relationship construction method, device, electronic equipment and storage medium | |
CN103678396A (en) | Data backup method and device based on data models | |
CN112181924A (en) | File conversion method, device, equipment and medium | |
CN114154468A (en) | Report synthesis method and device, electronic equipment and storage medium | |
CN112667664A (en) | Method and device for sentence conversion between databases, terminal equipment and medium | |
CN113722296A (en) | Agricultural information processing method and device, electronic equipment and storage medium | |
CN112818070A (en) | Data query method and device based on global data dictionary and electronic equipment | |
CN109697234B (en) | Multi-attribute information query method, device, server and medium for entity | |
CN103809915A (en) | Read-write method and device of magnetic disk files | |
CN116775599A (en) | Data migration method, device, electronic equipment and storage medium | |
CN111309988B (en) | Character string retrieval method and device based on coding and electronic equipment | |
CN113760237A (en) | Compiling address updating method and device, terminal equipment and readable storage medium |
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 | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20221012 Address after: 518000 Guangdong province Shenzhen Longgang District Bantian Street five and Avenue North 4012 Yuan Zheng Industrial Park. Applicant after: LAUNCH TECH Co.,Ltd. Address before: 518000 522, headquarters office building of Yuanzheng technology plant, No. 4012, North Wuhe Avenue, Bantian street, Longgang District, Shenzhen, Guangdong Province Applicant before: Shenzhen Yuanzheng Future Automobile Technology Co.,Ltd. |
|
TA01 | Transfer of patent application right | ||
GR01 | Patent grant | ||
GR01 | Patent grant |