Nothing Special   »   [go: up one dir, main page]

CN112486990B - Method and equipment for describing synchronous database table structure according to model - Google Patents

Method and equipment for describing synchronous database table structure according to model Download PDF

Info

Publication number
CN112486990B
CN112486990B CN202011363966.3A CN202011363966A CN112486990B CN 112486990 B CN112486990 B CN 112486990B CN 202011363966 A CN202011363966 A CN 202011363966A CN 112486990 B CN112486990 B CN 112486990B
Authority
CN
China
Prior art keywords
database
object model
model description
table structure
syntax tree
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.)
Active
Application number
CN202011363966.3A
Other languages
Chinese (zh)
Other versions
CN112486990A (en
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.)
Inspur General Software Co Ltd
Original Assignee
Inspur General Software 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 Inspur General Software Co Ltd filed Critical Inspur General Software Co Ltd
Priority to CN202011363966.3A priority Critical patent/CN112486990B/en
Publication of CN112486990A publication Critical patent/CN112486990A/en
Application granted granted Critical
Publication of CN112486990B publication Critical patent/CN112486990B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • G06F16/288Entity relationship models
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a method and equipment for describing a synchronous database table structure according to a model, which are used for solving the technical problem that the existing method for describing the database table structure cannot effectively manage the database table structure. The method comprises the following steps: abstracting the database table structure into a first database object model description; acquiring database connection information and setting information, and constructing a Hibernate service registration constructor; obtaining and analyzing a second database object model description, mapping the second database object model description into an abstract syntax tree, and generating entity classes according to the abstract syntax tree; wherein the second database object model description is modified based on the first database object model description; based on the Hibernate service registration constructor, an instance is created to generate a structured query language according to the differences between the entity class and the database table structure, synchronizing the database table structure. The method for managing and maintaining the database table structure intuitively and effectively ensures that the description of the database table structure is consistent with the description in the entity class.

Description

Method and equipment for describing synchronous database table structure according to model
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to a method and apparatus for describing a table structure of a synchronous database according to a model.
Background
In order to effectively manage the database table structure, the database table structure is often described uniformly, so that the database table structure is convenient to synchronize. The following three general description methods are available:
1. the table structure is described as an entity in the code by using an entity mapping framework (such as Hibernate, myBatis), and a mapping relation is established with the database by a labeling or configuration mode. However, the method can not enable a user to directly know how many tables exist in the whole product database, and also can not know the specific table structure of each table, so that the method has no intuitiveness.
2. A set of structures is used alone to describe the table structure and manage it. Although the structure of the database table can be clearly known in this way, because it is a separate structure, it cannot be checked, and it is difficult to ensure the correctness and consistency of the description.
3. The table structure is described using SQL statements. The method uses separate SQL statement description when the table structure is changed, and the SQL description of different types of databases is different, so that the management is complex and not intuitive.
Disclosure of Invention
The embodiment of the application provides a method and equipment for describing a synchronous database table structure according to a model, which are used for solving the technical problem that the existing method for describing the database table structure cannot effectively manage the database table structure.
In one aspect, an embodiment of the present application provides a method for describing a synchronous database table structure according to a model, including: abstracting the database table structure into a first database object model description; acquiring database connection information and setting information, and constructing a Hibernate service registration constructor; obtaining and analyzing a second database object model description, mapping the second database object model description into an abstract syntax tree, and generating entity classes according to the abstract syntax tree; wherein the second database object model description is modified based on the first database object model description; based on the Hibernate service registration constructor, an instance is created to generate a structured query language according to the differences between the entity class and the database table structure, synchronizing the database table structure.
In one implementation of the present application, abstracting a database table structure into a database object model description specifically includes: the table structures of the different types of databases are abstracted into a first database object model description.
In one implementation of the present application, the abstraction of the table structure of the different types of databases into a first database object model description specifically includes: based on the commonality of the table structures of the databases of different types, performing extended description on the characteristics of the table structures of the databases of different types to obtain a first database object model description; the first database object model describes commonalities and characteristics of table structures comprising different types of databases.
In one implementation of the present application, before mapping to the abstract syntax tree, the method further comprises: it is determined whether the modification of the second database object model description is compatible with the corresponding database.
In one implementation manner of the present application, the method for obtaining and analyzing the second database object model description, mapping the second database object model description to an abstract syntax tree, and generating an entity class according to the abstract syntax tree specifically includes: acquiring a database object model description list; mapping each second database object model description in the database object model description list into a corresponding abstract syntax tree; wherein each abstract syntax tree corresponds to an entity class; traversing the abstract syntax tree for each abstract syntax tree, and generating entity classes according to each node of the abstract syntax tree; wherein each node of the abstract syntax tree corresponds to each attribute of the corresponding second database object model description, respectively.
In one implementation of the present application, generating entity classes according to an abstract syntax tree specifically includes: generating entity class of the Hibernate mapping table structure according to the abstract syntax tree; wherein the entity class includes annotations of the Hibernate mapping table.
In one implementation of the present application, a structured query language is generated according to a difference between an entity class and a database table structure, and the database table structure is synchronized, specifically including: and comparing the differences between the structures listed in the entity class and the database table structures according to the mapping relation of the Hibernate mapping table to generate a creation or increment structured language and synchronize the database table structures.
In one implementation of the present application, after generating the entity class according to the abstract syntax tree, the method further includes: invoking a java command to compile the entity class to obtain a byte code file, and storing the byte code file into a script directory; the script directory is scanned and the bytecode file is loaded using a specified class loader.
In one implementation of the present application, before creating the instance, the method further includes: constructing a service registry using a Hibernate service registry constructor; creating a metadata source through a service registry; adding the compiled entity class into a marked class list of the metadata source; the marked class list is used for storing scanned compiled entity classes; and initializing the entity class and the mapping relation between the entity class and the database through the labels in the compiled entity class.
In another aspect, an embodiment of the present application further provides an apparatus for describing a table structure of a synchronous database according to a model, where the apparatus includes: a processor; and a memory having executable code stored thereon that, when executed, causes the processor to perform a method of synchronizing database table structures according to a model description as described above.
The method and the device for describing the table structure of the synchronous database according to the model at least have the following beneficial effects: the database table structure is abstracted into the description of the database object model, and the synchronization of the table structure is achieved by using the model to be desynchronized, so that the database table structure can be intuitively and effectively managed. Based on the Hibernate, SQL is generated according to the difference between the entity class and the database table structure to synchronize the database table structure, so that the problem that the table database table structure is possibly inconsistent with the description in the entity class is solved. In addition, hibernate is a Java framework, and the present application integrates synchronization of database table structures with Hibernate, so that database object model descriptions can be applied in Java language.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
FIG. 1 is a flowchart of a method for describing a table structure of a synchronous database according to a model according to an embodiment of the present application;
fig. 2 is a schematic diagram of an apparatus for describing a table structure of a synchronous database according to a model in an embodiment of the present application.
Detailed Description
For the purposes, technical solutions and advantages of the present application, the technical solutions of the present application will be clearly and completely described below with reference to specific embodiments of the present application and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
In order to realize the synchronous database table structure and maintain and manage the same, the table structure of the database is often described in a unified way. The following three general description methods are available: the table structure is described by adopting a Java related entity mapping framework, using a single structure and using SQL sentences.
The Java related entity mapping framework (for example Hibernate, myBatis) synchronizes the table structure based on the mapping relationship between the entity class and the database table structure, and this method cannot enable the user to directly know how many tables are in the whole product database, and also cannot know the specific table structure of each table, which is not intuitive.
The structure of the database table can be clearly described by using a single structure, but because the structure is an independent structure, the structure does not have a connection relation with the database and the codes, and cannot be checked, the description correctness and the consistency of the database table structure are difficult to ensure.
The table structure is described by using SQL sentences, the method is described by using separate SQL sentences when the table structure is changed, and the user cannot intuitively know the table structure because the whole table structure is known and the whole table structure is also required to be executed by the separate SQL sentences. And SQL sentences of different types of databases are different, and management is complex.
The embodiment of the application provides a method and equipment for describing a synchronous database table structure according to a model, which are used for solving the technical problem that the existing method for describing the database table structure cannot effectively manage the database table structure.
The following describes in detail the technical solution proposed in the embodiments of the present application through the accompanying drawings.
Fig. 1 is a flowchart of a method for describing a table structure of a synchronous database according to a model in an embodiment of the present application. As shown in fig. 1, the method for synchronizing a database table structure according to a model description provided in the embodiment of the present application mainly includes the following steps:
s101, abstracting a database table structure into a first database object model description.
The server performs a modeled description of the database table structure, abstracting it as a first database object model description.
Wherein the database object model description is in JSON format. For example, { "field number": "1", "field name": "name", "the term" is "the term", { "field number": "2", "field name": "age", "the term" is "the term" }.
In one embodiment of the present application, the server may abstract the table structure of the different types of databases into a first database object model description according to a predefined database object model description. The modeling description of the database object is formed on the abstract basis of various database table structures, and the unified description of the table structures of different database types is realized. Among other things, different types of relational databases may include MySQL, oracle, SQL Server, DB2, and the like. One of them does not represent a specific number but represents a uniform manner of description.
Embodiments provided herein support synchronization of multiple types of database table structures such that a description can map multiple database table structures, and by modifying such a description, table structures for multiple different types of databases can be automatically created and updated, making it easier to manage.
In one embodiment of the present application, the server may perform extended description on the characteristics of the table structures of the different types of databases based on the commonalities of the table structures of the different types of databases, to obtain a first database object model description. The first database object model describes commonalities and characteristics of table structures comprising different types of databases. Wherein, commonality refers to the approximately same content and characteristics in the descriptions of various relational database object table structures, and refers to the descriptions of specific fields in the database table structures.
The description of the table structures of various relational database objects is basically consistent, and mainly comprises table names, field list descriptions, index list descriptions and constraint descriptions. Wherein the field list is a list of a plurality of fields in the database table, the index list is a list of database indexes, and the constraints include checking constraints, field constraints, and the like. For each field in the database table, further extended descriptions are often made, such as field name, field length, field precision, etc. The various relational databases typically have field descriptions of the above types, but the databases are not identical for descriptions of the same field type. The application abstracts a first database object model description, including a structure description and a field type description. The structure description is abstracted based on the commonalities of various relational database table structures, and comprises table names, field list descriptions, index list descriptions and constraint descriptions; the field type description is an extended description for the characteristics of various relational database table structures, namely, the field types, and comprises the attributes of field numbers, field names, lengths, precision, decimal numbers, whether primary keys are non-null, unique and the like.
Through modeling description, the table structure of the database can be intuitively maintained and managed, and a user can know how many tables exist in the product database and the specific structure of each table, so that the method has intuitiveness.
S102, acquiring database connection information and setting information, and constructing a Hibernate service registration constructor.
The server may obtain database connection information and setting information for configuring the Hibernate service registration constructor based on user input. The database connection information comprises information related to connection of the database, such as a database connection URL, a user name, a password, a driver, a dialect, automatic submission or the like, and the setting information comprises information of whether SQL sentences are printed, whether the printed SQL is displayed in a formatted mode or not, a table structure updating strategy and the like.
In one embodiment of the present application, when determining relevant information of a database input by a user, the server may send display prompt information to the user according to a default value preset by each information, so as to be used by the user for selection. This can simplify the user operation and facilitate the use. For example, each database port number is displayed as a default port number.
In one possible implementation manner, the server can determine information input by a user through a visualization tool with a user operation interface, support setting of connection information of different types of databases, realize synchronization of different types of database table structures, and be used for subsequent operations such as generating entity classes, compiling and loading entity classes, synchronizing database table structures and the like.
One possible manifestation of the Hibernate service registration builder configuration information is shown in table 1:
TABLE 1
Figure BDA0002804866620000071
The first column of table 1 is configuration information required for constructing the Hibernate service registration constructor, and the second column is a description of the configuration.
The server automatically constructs information identifiable by the Hibernate such as URL and user name according to the input database connection information, and determines the database connection driver and dialect according to the input database type, and finally completes the configuration in the table to construct the Hibernate service registration constructor.
S103, obtaining and analyzing the object model description of the second database, mapping the object model description into an abstract syntax tree, and generating entity classes according to the abstract syntax tree.
In one embodiment of the present application, after the database object model description changes, in order to ensure consistency between the database table structure and the model description, the server needs to obtain and parse the second database object model description, map it into an abstract syntax tree, and traverse the abstract syntax tree to generate an entity class.
Specifically, the first database object model description is obtained on the basis of abstractions of various database table structures, and when the description is modified, the second database object model description is obtained. The server may obtain the model description through the catalog of the second database object model description file and convert it to code.
In one embodiment of the present application, modifications to the database object model description may not match the database, cannot be synchronized into the database, and may even cause an abnormal operation condition, so before mapping the second database object model description into the abstract syntax tree, it should be determined whether the modifications to the second database object model description are compatible with the corresponding database.
Specifically, the Hibernate service registration builder creates a sessionfactor instance for checking whether the modification of the second database object model description is compatible with the corresponding database. If compatible, allowing such modification, the server may map the second database object model description to an abstract syntax tree; if not, the modification is not allowed and the program may be terminated by throwing an exception.
For example, if the data type of the "age" field is changed from the int type to the varchar type in the model description, the database itself is not compatible with such modifications, and such modifications are not allowed; if the field length of the "number" field is changed from 20 to 5 in the model description, the field length is shortened, but since the number is generally longer, such modification is easy to cause the data to be truncated and lose integrity, and such modification is not allowed.
And judging whether the modification of the description of the second database object model is compatible with the corresponding database table, so that the structure of the description of the database object model is consistent with that of the database table, and the normal operation of tool logic can be ensured.
In one embodiment of the present application, when generating entity classes from second database object model descriptions, the server first obtains a database object model description list, and maps each second database object model description in the database object model description list to a corresponding abstract syntax tree. And traversing each abstract syntax tree, and generating entity classes according to each node of the abstract syntax tree.
It should be noted that, the attributes of the database object model descriptions are the same, and the values corresponding to the attributes are different, so that a database object model description list is formed, and each database object model description in the list corresponds to one table in the database.
Specifically, when the server determines that the model description has modification, firstly, acquiring a database object model description list, screening out the modified description in the list, namely, a second database object model description, and mapping the second database object model description into an abstract syntax tree (Abstract Syntax Tree, AST); then traversing each abstract syntax tree, and generating entity classes according to each node of the abstract syntax tree. An abstract syntax tree is a tree-like representation of the abstract syntax structure of source code, each node on the tree representing a structure in the source code, independent of the concrete syntax, independent of the language details. Each node of the abstract syntax tree provided by the embodiment of the application corresponds to each attribute of the corresponding second database object model description.
In one embodiment of the application, when the server generates the entity class, the entity class of the Hibernate mapping table structure can be generated according to the abstract syntax tree; wherein the entity class includes annotations of the Hibernate mapping table.
Specifically, the embodiment of the application provides a syntax tree generating framework of an entity generating a Hibernte mapping table structure, which can convert each attribute of model description into a node of an abstract syntax tree and then generate Java entity class according to the abstract syntax tree. The generated entity class comprises a label of a Hibernate mapping table besides codes for logic processing. The Hibernate can complete mapping between Entity classes and database objects based on a labeling mode, and the specific mapping mode is that an Entity class is mapped by @ Entity, a Table associated with the Table is designated by @ Table, information of a field corresponding to a database is designated by @ Column, and the like.
In one embodiment of the present application, the server dynamically compiles the entity class after generating the entity class from the abstract syntax tree. The process of dynamically compiling entity class is as follows:
first, the location of the entity class, the compiling generation location and the referred jar packet path are specified, and a DiagnosticCollector object is established.
And secondly, acquiring a file management instance of the Java compiler according to the DiagnosticCollector object.
And then converting the java file under the entity class path into a compiling unit required by the compiling task.
And finally, calling a java command to compile the compiling unit to obtain a class file and storing the class file into a script directory.
In one embodiment of the present application, the server dynamically compiles the entity class and then loads the entity class.
Specifically, the Hibernate service registration constructor scans the script directory and loads the class file using the specified class loader LaunchelslassLoader. Only when a specific loader is used for loading the compiled entity class, the labels in the entity class can be analyzed, so that the database table structure is synchronized.
S104, creating an instance, generating a structured query language according to the difference between the entity class and the database table structure, and synchronizing the database table structure.
The Hibernate service registration constructor re-creates a SessionFactory instance, initializes the mapping relationship between entity classes and database objects, generates SQL statements based on the mechanism of Hibernate creation and update of the table structure, and synchronizes the database table structure.
In one embodiment of the present application, prior to creating an embodiment, a service registry is first constructed using a Hibernate service registry constructor, through which metadata sources are created. And adding the scanned class file into a marked class list of the metadata source, and initializing entity classes and mapping relations between the entity classes and the database through marking in the class file.
In one embodiment of the present application, after initializing the entity class and its mapping relationship with the database, the differences between the structure listed in the entity class and the database table structure are compared to generate a create or increment SQL, synchronize the database table structure.
It should be noted that, the method for synchronizing the table structure of the database according to the model description provided in the embodiment of the present application is implemented by integrating the model description with the Hibernate. The Hibernate will re-create a SessionFactory instance at this time, read the structure of the entity column in the code and compare with the structure of the table in the database, produce and create or increment SQL, update. Where incremental SQL refers to SQL statements generated from differences between entity classes and database table structures.
Specifically, the mapping relationship is shown in table 2:
TABLE 2
Figure BDA0002804866620000101
Figure BDA0002804866620000111
Wherein, the first column of table 2 is the respective attributes in the database object model description, the second column is the description in the entity class corresponding to the database object model description, and the third column is the description of the database object having the mapping relation with the database object model description.
According to the method for synchronizing the database table structure according to the model description, the table structures of different database types are subjected to modeling description, the modeling description is then converted into entity types, and the mechanism of establishing and updating the table by calling the Hibernate is used for synchronizing the database table structure. The method can intuitively manage the database table structure, can ensure that the description of the database table structure is consistent with the description in the entity class, and can be applied to Java because the synchronization of the database table structure and the Hibernate are integrated.
The foregoing is a method embodiment presented herein. Based on the same inventive concept, the embodiment of the present application also provides an apparatus for synchronizing a database table structure according to a model description, as shown in fig. 2.
Fig. 2 is a schematic diagram of an apparatus for describing a table structure of a synchronous database according to a model in an embodiment of the present application. As shown in fig. 2, the apparatus comprises a processor 201, and a memory 202 having executable code stored thereon, which when executed causes the processor 201 to perform a method of synchronizing database table structures according to a model description as described above.
In one embodiment of the present application, the processor 201 is configured to abstract the database table structure into a first database object model description; acquiring database connection information and setting information, and constructing a Hibernate service registration constructor; obtaining and analyzing a second database object model description, mapping the second database object model description into an abstract syntax tree, and generating entity classes according to the abstract syntax tree; wherein the second database object model description is modified based on the first database object model description; based on the Hibernate service registration constructor, an instance is created to generate a structured query language according to the differences between the entity class and the database table structure, synchronizing the database table structure.
All embodiments in the application are described in a progressive manner, and identical and similar parts of all embodiments are mutually referred, so that each embodiment mainly describes differences from other embodiments. In particular, for the apparatus embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments in part.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (8)

1. A method of synchronizing database table structures according to a model description, the method comprising:
abstracting the database table structure into a first database object model description;
acquiring database connection information and setting information, and constructing a Hibernate service registration constructor;
obtaining and analyzing a second database object model description, mapping the second database object model description into an abstract syntax tree, and generating entity classes according to the abstract syntax tree; wherein the second database object model description is modified based on the first database object model description;
creating an instance based on the Hibernate service registration constructor to generate a structured query language according to the differences between the entity class and the database table structure, and synchronizing the database table structure;
abstracting the database table structure into a first database object model description, wherein the method specifically comprises the following steps:
abstracting the table structures of the databases of different types into a description of the object model of the first database;
abstracting the table structure of the databases of different types into a description of the object model of the first database, wherein the method specifically comprises the following steps:
based on the commonality of the table structures of the databases of different types, performing extended description on the characteristics of the table structures of the databases of different types to obtain a description of the object model of the first database; the first database object model describes commonalities and characteristics of table structures comprising the different types of databases.
2. A method of synchronizing database table structures according to a model description according to claim 1, characterized in that before mapping into an abstract syntax tree, the method further comprises:
and judging whether the modification described by the second database object model is compatible with the corresponding database.
3. The method for synchronizing database table structures according to model description of claim 1, wherein obtaining and parsing the second database object model description, mapping to an abstract syntax tree, generating entity classes according to the abstract syntax tree, specifically comprises:
acquiring a database object model description list;
mapping each second database object model description in the database object model description list into a corresponding abstract syntax tree; wherein each abstract syntax tree corresponds to one entity class;
traversing the abstract syntax tree for each abstract syntax tree, and generating the entity class according to each node of the abstract syntax tree; wherein each node of the abstract syntax tree corresponds to each attribute of the corresponding second database object model description, respectively.
4. A method for synchronizing database table structures according to a model description as claimed in claim 3, wherein generating entity classes from the abstract syntax tree comprises:
generating entity classes of a Hibernate mapping table structure according to the abstract syntax tree;
wherein the entity class includes labels of the Hibernate mapping table.
5. The method for synchronizing a database table structure according to a model description of claim 4, wherein generating a structured query language based on the differences between the entity class and the database table structure, synchronizing the database table structure, comprises:
and comparing the differences between the column structures in the entity class and the database table structures according to the mapping relation of the Hibernate mapping table to generate a creation or increment structured language, and synchronizing the database table structures.
6. The method of claim 1, wherein after generating the entity class from the abstract syntax tree, the method further comprises:
invoking a java command to compile the entity class to obtain a byte code file, and storing the byte code file into a script directory;
scanning the script directory, and loading the byte code file by using a specified class loader.
7. The method for synchronizing database table structures according to a model description of claim 6, wherein prior to creating the instance, the method further comprises:
constructing a service registry by using the Hibernate service registration constructor;
creating a metadata source through the service registry;
adding the compiled entity class to a marked class list of the metadata source; the marked class list is used for storing the scanned compiled entity class;
initializing the entity class and the mapping relation between the entity class and a database through the label in the compiled entity class.
8. An apparatus for synchronizing database table structures according to a model description, the apparatus comprising:
a processor;
and a memory having executable code stored thereon that, when executed, causes the processor to perform a method of dynamically synchronizing database table structures according to a model description as claimed in any one of claims 1 to 7.
CN202011363966.3A 2020-11-27 2020-11-27 Method and equipment for describing synchronous database table structure according to model Active CN112486990B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011363966.3A CN112486990B (en) 2020-11-27 2020-11-27 Method and equipment for describing synchronous database table structure according to model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011363966.3A CN112486990B (en) 2020-11-27 2020-11-27 Method and equipment for describing synchronous database table structure according to model

Publications (2)

Publication Number Publication Date
CN112486990A CN112486990A (en) 2021-03-12
CN112486990B true CN112486990B (en) 2023-05-02

Family

ID=74936562

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011363966.3A Active CN112486990B (en) 2020-11-27 2020-11-27 Method and equipment for describing synchronous database table structure according to model

Country Status (1)

Country Link
CN (1) CN112486990B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113486010A (en) * 2021-07-01 2021-10-08 远光软件股份有限公司 Database synchronization method, device, server and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1840767A2 (en) * 2006-03-28 2007-10-03 Sun Microsystems, Inc. Systems and methods for a distributed cache
CN106649771A (en) * 2016-12-27 2017-05-10 广州杰赛科技股份有限公司 Data model updating method and system for database
CN106844693A (en) * 2017-01-24 2017-06-13 浙江大学 A kind of conversion methods of openEHR Template to relational database
CN106933837A (en) * 2015-12-29 2017-07-07 航天信息股份有限公司 A kind of database table model and creation method
CN107741847A (en) * 2017-10-11 2018-02-27 江苏千米网络科技股份有限公司 Realize the method and device of domain-driven model
CN108037913A (en) * 2017-12-21 2018-05-15 西安邮电大学 A kind of conversion method of xUML4MC models to MSVL LISP program LISPs, computer program
CN110275709A (en) * 2018-03-15 2019-09-24 阿里巴巴集团控股有限公司 Processing and optimization method, device, equipment and storage medium for dynamic language
CN110866012A (en) * 2019-11-11 2020-03-06 北京知道创宇信息技术股份有限公司 Table structure management method, device, server and readable storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1840767A2 (en) * 2006-03-28 2007-10-03 Sun Microsystems, Inc. Systems and methods for a distributed cache
CN106933837A (en) * 2015-12-29 2017-07-07 航天信息股份有限公司 A kind of database table model and creation method
CN106649771A (en) * 2016-12-27 2017-05-10 广州杰赛科技股份有限公司 Data model updating method and system for database
CN106844693A (en) * 2017-01-24 2017-06-13 浙江大学 A kind of conversion methods of openEHR Template to relational database
CN107741847A (en) * 2017-10-11 2018-02-27 江苏千米网络科技股份有限公司 Realize the method and device of domain-driven model
CN108037913A (en) * 2017-12-21 2018-05-15 西安邮电大学 A kind of conversion method of xUML4MC models to MSVL LISP program LISPs, computer program
CN110275709A (en) * 2018-03-15 2019-09-24 阿里巴巴集团控股有限公司 Processing and optimization method, device, equipment and storage medium for dynamic language
CN110866012A (en) * 2019-11-11 2020-03-06 北京知道创宇信息技术股份有限公司 Table structure management method, device, server and readable storage medium

Also Published As

Publication number Publication date
CN112486990A (en) 2021-03-12

Similar Documents

Publication Publication Date Title
US11726969B2 (en) Matching metastructure for data modeling
US8516437B2 (en) System and method for creating, managing, and reusing schema type definitions in services oriented architecture services, grouped in the form of libraries
US9465590B2 (en) Code generation framework for application program interface for model
US5418957A (en) Network data dictionary
EP1347394B1 (en) Schema-oriented content management system
US7174533B2 (en) Method, system, and program for translating a class schema in a source language to a target language
US7676493B2 (en) Incremental approach to an object-relational solution
US20050071805A1 (en) Developing applications using a metamodel
US20050108684A1 (en) Method and system for generating an application object repository from application framework metadata
CN111813798B (en) Mapping method, device, equipment and storage medium based on R2RML standard
US10019243B2 (en) Packaging system to facilitate declarative model-driven development
US11561976B1 (en) System and method for facilitating metadata identification and import
CN110489401B (en) Method and device for deploying database objects
CN112650526B (en) Method, device, electronic equipment and medium for detecting version consistency
CN116414774A (en) File migration method, device, equipment and storage medium
CN112486990B (en) Method and equipment for describing synchronous database table structure according to model
WO2021022703A1 (en) Software project reconstruction method and device, and computer device and storage medium
WO2005055561A2 (en) System and method for managing oss component configuration
US20100088283A1 (en) System and method for managing database applications
US11940951B2 (en) Identification and import of metadata for extensions to database artefacts
US20050114642A1 (en) System and method for managing OSS component configuration
Blow et al. Updates in the aqualogic data services platform
US20100023923A1 (en) Method for medeling objects in a hetrogenious computing environment
Bell Adding Functions and Commands to MySQL
CN115048109A (en) Code generation method and device based on metadata

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: 20230321

Address after: 250101 Inspur science and Technology Park, 1036 Inspur Road, hi tech Zone, Jinan City, Shandong Province

Applicant after: Inspur Genersoft Co.,Ltd.

Address before: 250101 Inspur science and Technology Park, 1036 Inspur Road, hi tech Zone, Jinan City, Shandong Province

Applicant before: SHANDONG INSPUR GENESOFT INFORMATION TECHNOLOGY Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant