CN106844643A - A kind of Database Dynamic generation method based on template engine - Google Patents

A kind of Database Dynamic generation method based on template engine Download PDF

Info

Publication number
CN106844643A
CN106844643A CN201710045933.6A CN201710045933A CN106844643A CN 106844643 A CN106844643 A CN 106844643A CN 201710045933 A CN201710045933 A CN 201710045933A CN 106844643 A CN106844643 A CN 106844643A
Authority
CN
China
Prior art keywords
data
database
class
template
interface
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.)
Withdrawn
Application number
CN201710045933.6A
Other languages
Chinese (zh)
Inventor
王洋
叶周
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN201710045933.6A priority Critical patent/CN106844643A/en
Publication of CN106844643A publication Critical patent/CN106844643A/en
Withdrawn legal-status Critical Current

Links

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/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Abstract

The present invention provides a kind of Database Dynamic generation method based on template engine, it is characterised in that including:Parse and the configuration information in package arrangements file is to generate data message;Based on database and database table described in the data message dynamic creation;The data information transfer is generated into class file to data model template and in the presence of template engine;Class object is created based on the class file, and object type is forced to switch to interface type;The operating method of the operate interface is called to realize database manipulation using the operate interface of database described in data model stencil design and according to interface type foundation.The achievable database generation of the present invention, storage, the unitized and convenience of inquiry, realize the demand of various data volume storages.

Description

A kind of Database Dynamic generation method based on template engine
Technical field
The present invention relates to field of computer technology, more particularly to a kind of Database Dynamic generation side based on template engine Method.
Background technology
Database technology results from beginning of the seventies late 1960s, and its main purpose is effectively to manage and access big The data resource of amount.Database technology is mainly studied and how stored, and uses and manage data.Over several years, database technology and meter The development of calculation machine network technology is interpenetrated, and is mutually promoted, it has also become computer nowadays field quickly grows, and widely used two Big field.Database technology is not only applicable to issued transaction, and is further applicable to information retrieval, artificial intelligence, expert system The fields such as system, big data.The Database Systems of main flow include MySQL, MariaDB, MongoDB, HBase, Microsoft SQL Server, Oracle, DB2 etc..
Database interface is the technology being connected with Database.Current most popular two kinds of database interfaces be ODBC and JDBC.ODBC (Open Database Connectivity) technology that Microsoft is released is carried for the access of heterogeneous database Unified interface is supplied.ODBC is based on SQL, and as the standard of access database.JDBC(Java Database Connectivity) it is a kind of Java API for performing SQL statement, unified visit can be provided for various relational databases Ask, be made up of one group of class write using Java language and interface.
Under normal circumstances, no matter using which kind of program language such as PHP, Java, C/C++, C#, it is related to the related behaviour of database Make, developer is the structure for being known a priori by database, and specific operation is performed for specified services.As finished writing data in advance The script of table and database insertion is built in storehouse, presets for operation for specifying tables of data etc..And now easily trigger a series of Problem:
(1) in cases where an amount of data is large, database builds the number that the operation such as table handling and data preservation and inquiry is related to Can also be increased according to amount.
(2) in the case where data volume does not know or data volume is frequently necessary to modification, developer needs to spend a large amount of Time is on modification database manipulation interface code.
(3) if the property of many data services is consistent, for example, the different pieces of information bag of test data is all, completely may be used To integrate, code is write in the operation without being individually for each packet.
(4) when amount of user data changes, it is necessary to developer remodifies data processing and database manipulation code, directly Connect the workload for reducing Consumer's Experience and developer.
Later developer is to avoid frequently changing data volume to cause when database development frequently modification code Problem, using the method for configuration file dynamic creating table, builds storehouse and only needs to more new configuration file again.But there are two problems not have all the time Have and effectively solved:
(1) dynamic data operation, data volume and database table dynamically update, but the operation such as the storage and inquiry of database is still Individually modification is needed, in other words, data model and data manipulation method are not unified yet, database associative operation is still needed to for spy Determine data model.
(2) final operate interface is not handed over to user terminal completely, once user's amount of updating the data, it is still necessary to developer Changed accordingly, user can not be completely independent operating database.
The content of the invention
The technical problem that technical solution of the present invention is solved is how to provide a kind of database production method to realize data Library storage, the unitized and convenience of inquiry, realize the demand of various data volume storages.
In order to solve the above-mentioned technical problem, technical solution of the present invention provides a kind of Database Dynamic based on template engine Generation method, including:
Parse and the configuration information in package arrangements file is to generate data message;
Based on database and database table described in the data message dynamic creation;
The data information transfer is generated into class file to data model template and in the presence of template engine;
Class object is created based on the class file, and object type is forced to switch to interface type;
Object tune is set up using the operate interface of database described in data model stencil design and according to the interface type With the operating method of the operate interface setting up the interaction of external data source and the database.
Optionally, the Database Dynamic generation method also includes:Configure the configuration file;The configuration information is at least Including:Database information system, database server information, database accounts information, database engine information, database coding Information, database table name, database table field information.
Optionally, the parsing includes:XML is parsed or JOSN parsings.
Optionally, the configuration information refers to the data model class of generation and its configuration information of attribute, in the template Under the driving of engine, configuration information is filled to the data model template, you can one available data class of generation;
It is described that class file bag is generated by the data information transfer to data model template and in the presence of template engine Include:Generate the data class and form the class file by from compiling.
Optionally, it is described to include from compiling:
By the way of JavaCompiler+CompilationTask in JDK, it is necessary to incoming Java source files path and Specify Class compiling catalogue, after compile successfully will compiling catalogue under according to bag coordinates measurement class file
Optionally, the configuration information includes database table configuration information and data model configuration information;The database Table configuration information and data model configuration information are one-to-one.
Optionally, the Database Dynamic generation method also includes:The data model template is driven using template engine, The template engine is FreeMarker template engines.
Optionally, it is described that class object is created based on the class file, and object type is forced to switch to interface type and include:
Data manipulation method is called, is bypassed and is directly generated data class object, object, Ran Houqiang are created by the form for reflecting System is converted to the type of data operating interface.
Optionally, it is described to call data manipulation method at least including the one kind in following operation:Data assignment, data take Value, preserve data to data storehouse in, from data base querying data.
Optionally, data assignment operation includes:The all of number in batch setting data class defined in data operating interface According to value, the type and length according to each data volume or attribute change extraction data actual value in byte stream one by one, then call The Setter methods of correspondence attribute set its value;
The operation of data value includes:The inverse process of data assignment, i.e., call first defined in data operating interface Getter methods obtain the actual value of all properties in data class, are then converted and are stored in pre-assigned byte arrays In;
Being operated in preservation data to data storehouse includes:The model data class that generation is preserved defined in data operating interface is each Data volume or attribute have spliced a SQL INSERT sentence, the name based on attribute in specified database according to attribute list Claim to preserve database realizing dynamic operation with Database field title concord;
It is included in defined in data operating interface according to search condition from specified database from data base querying data manipulation Each field value of corresponding table is inquired about, is parsed and to the attribute assignment of data class, a SQL has been spliced according to attribute list SELETE sentences with realize inquire about database dynamic operation.
The beneficial effect of technical solution of the present invention at least includes:
As the one side of technical solution of the present invention, there is provided developer dynamically generates database, dynamic operation number According to the method in storehouse, and can solve the problems, such as frequently to change the frequent modification code of data volume or the larger initiation of data volume;As this The another aspect of inventive technique scheme, technical solution of the present invention for user realize only need to be by changing profile information sum The method for quickly generating database of database manipulation demand can be met according to incoming interface, without being concerned about any internal database Operation relevant issues, the process of database needed for generation is simple, efficient.
Technical solution of the present invention is suitable for the industry needs of the continuous improvement of data storage requirement, carry out data storage and While inquiry, the data volume storage demand being continually changing can be met, improve the flexibility of database manipulation, be favorably improved out Hair efficiency.
Data storage and inquiry operation after technical solution of the present invention data library generating method, or even database generation are Dynamic implement, user such as need to the amount of updating the data, it is only necessary to change configuration file, simple to operate and realize that operation is unitized And convenience;Technical solution of the present invention also by template engine and combine interface operation, it is polymorphic, from technique of compiling, skill of the present invention The generation of the data class of art scheme, compiling and Object Creation, so call data manipulation method whole process be all it is dynamic, Realize the coherency operation under data volume scene change.
Brief description of the drawings
The detailed description made to non-limiting example with reference to the following drawings by reading, other features of the invention, Objects and advantages will become more apparent upon:
Fig. 1 shows for a kind of flow of Database Dynamic generation method based on template engine that technical solution of the present invention is provided It is intended to;
Fig. 2 is the input/output relation schematic diagram of template and data model in technical solution of the present invention;
Fig. 3 is that the algorithm frame of the Database Dynamic generation method based on template engine in technical solution of the present invention is illustrated Figure;
Fig. 4 is the structural representation of the first example of configuration file in technical solution of the present invention.
Specific embodiment
In order to preferably make technical scheme clearly show, the present invention is made into one below in conjunction with the accompanying drawings Step explanation.
Technical solution of the present invention provides a kind of side of Database Dynamic generation, storage and operation based on template engine Method, technical problem to be solved is:The operations such as how database dynamically generates, dynamic memory and inquiry;How data build Unified model, performs unified operation.The present invention by configuration file, template engine, interface with it is polymorphic, from compiling with reflection, The technologies such as data conversion, database interface are combined, and solve the unification of data model and dynamic generation, storage, the inquiry of database Etc. operating method.
The concept noun and portion of techniques flow being related to technical solution of the present invention below are explained and defined.Specifically:
Technical solution of the present invention includes:Configuration file, configuration information of the configuration file comprising model data class and data Storehouse configuration information, both are to be mutually related, data class correspondence database, the field of the attribute correspondence database table of data class, The level of configuration information from top to bottom for database information->Packet or table information->Data volume or literary name segment information;Comprising matching somebody with somebody The parsing of file is put, according to configuration file type, the parsing of XML or JSON etc. is realized;Comprising data encapsulation, including data class The encapsulation of (database table) information and data volume (literary name section) information.
Technical solution of the present invention includes:Template engine, the template engine can be used FreeMarker to realize, FTL templates are matched somebody with somebody Putting content includes class name, bag name, importing bag, succession, realization, attribute, method etc..FTL templates support parameter incoming and parsing, with Data are implemented in combination with final class output, support FTL grammers label and variable-definition, for the control of FTL template procedures.
Technical solution of the present invention includes:Interface and the polymorphic unified operation for aiming at data class, define one it is general Data operating interface, defines data manipulation method in the interface.Data class is generated by FTL template configurations and realizes that data manipulation connects Mouthful, and make carbon copies data manipulation method.Then it is interface type by generation class object unsteady state operation, just can be united by the way of polymorphic One calls data manipulation method.
Technical solution of the present invention includes:From compiling and reflection, using self-generating, the strategy from compiling, without outside Developing instrument or Java compiler directives, cause that compilation operations become controllable from compiling.According to Class compiling files path, use The method of reflection creates object, with polymorphic mode calling interface operating method.From generation, compilation model data class, to establishment Class object, the whole process of execution interface method are all dynamic implements.
Technical solution of the present invention includes:Data conversion is unified data manipulation, takes directly incoming byte arrays to join Several form, because integer type data, real-coded GA and character string type data, can realize phase between byte arrays Mutually conversion.
Technical solution of the present invention includes:Database interface, by the way of JDBC, database and database table can bases Configuration information is dynamically generated, and the operation such as database purchase and inquiry is then realized in the method for data operating interface.In FTL moulds In plate, substantially splice SQL statement using attribute list.
In the overall flow method of technical solution of the present invention, as shown in Figure 1 there is provided a kind of number based on template engine According to storehouse dynamic creation method, including below scheme:
Step S100, parses and the configuration information in package arrangements file is to generate data message.
According to step S100, the configuration file is set to one with posting port, and it can as needed by arbitrary disposition.Specifically , in other embodiments, the method for technical solution of the present invention may also include the step of configuring the configuration file, in the present invention Can then be implemented as an outside input step in one embodiment of technical scheme.Specifically, data item configuration is by matching somebody with somebody The mode for putting file realizes that such as XML/JSON, configuration information includes database configuration information and model data configuration information.
Information type and the information content in configuration information detailed below:
The database configuration information includes Database Systems, database server information, database accounts information, data The information such as storehouse engine, database coding, database table name, database table field.
The Database Systems support Sybase system, such as MySQL, MariaDB, MongoDB, HBase and Oracle, Microsoft SQL Server etc..
The database engine such as MySQL database supports MyISAM and InnoDB, and the configuration can also be empty, then use number According to storehouse system default engine.
The database server information includes database server address and its port.
The database accounts information refers to the database user information that can obtain database connection and operating right, including Database user name and password.
Database coding such as MySQL database support utf8_unicode_ci, utf8_general_ci, Gb2312_chinese_ci, gbk_chinese_ci etc..
The database table field information include field name, field type, field default value, field annotation, field index, Belonging to field and field other service related informations affiliated group of such as field etc..Wherein field type is data type, number According to the set of length and data attribute;Field index includes index name and type, can also be empty.
The model data configuration information refers to the data model class of generation and its configuration information of attribute, in template engine Driving under, model data configuration information is filled to data template, you can generation one available data class.
The data model class configuration information includes the class name of data class, class bag name and class description.
The data model generic attribute configuration information includes that Property Name, attribute type, attribute description, attribute take byte The information such as length.
The naming rule of the Property Name should follow programming language variable naming specification;Attribute type supports master data Type and reference type, if reference type, then add the configuration information of the reference type first;Attribute take byte length with The affiliated type of attribute takes byte length should be consistent.
The configuration information and model data configuration information of affiliated database table are one-to-one, i.e., one database tables pair Answer a data class, the configuration information and data attribute configuration information of database table field are one-to-one, i.e. database tables An attribute in one field corresponding data class.
Firstly the need of by parsing, such as XML parsings, JOSN parsings, could be template data to model data configuration information Class is generated and database manipulation is used.It should be noted that the analysis mode of technical solution of the present invention is not limited to examples detailed above, Can realize that the analysis mode that model data is configured is also feasible using other in other embodiments.
With continued reference to Fig. 1, according to a kind of Database Dynamic generation based on template engine that technical solution of the present invention is provided Method, also includes:
Step S101, based on database and database table described in the data message dynamic creation.
What technical solution of the present invention meaning database and database table were automatically generated, its detailed process includes that connection is specified Database Systems (JDBC), database are created and database table is automatically generated.The connection specified database system, be Refer to the database server information and database accounts information by configuring, connect the Database Systems specified by configuration. In Java, database-driven is realized by JDBC, and JBDC supports most of Database Systems operation.
The database is created, and refers to that can automatically create database, it is possible to specify database-name, it is also possible to during foundation Between information generation database-name, to adapt to various demands.The database table is automatically generated, and refers to the database according to configuration Table information and all field informations, automatically create database table.
With continued reference to Fig. 1, according to a kind of Database Dynamic generation based on template engine that technical solution of the present invention is provided Method, also includes:
Step S102, class text is generated by the data information transfer to data model template and in the presence of template engine Part.
The S102 according to the step of technical solution of the present invention, the configuration information refers to the data model class and its attribute of generation Configuration information, under the driving of the template engine, configuration information is filled to the data model template, you can generation one Available data class;It is described that class text is generated by the data information transfer to data model template and in the presence of template engine Part includes:Generate the data class and form the class file by from compiling.
Specifically, in one embodiment of technical solution of the present invention, the data model template is FreeMarker moulds Plate, the template engine is FreeMarker template engines, and its template writes language for FreeMarker Template Language (FTL) language.
More specifically, the FreeMarker template engines are a kind of based on template and the data to be changed, and are used for The general utility tool of generation output text (html web page, Email, configuration file, source code etc.).It is not towards final use Family, but a java class storehouse.FreeMarker is free, based on the issue of the version of Apache licensings 2.0.Its template is compiled FreeMarker Template Language (FTL) are written as, belong to simple, special language.With reference to Fig. 2, template (temple) and data model (Java objects) to be FreeMarker generate part necessary to output:Template+ Data model=output (Output).
More specifically, the FreeMarker template engines, support the template of configuration standard java class syntax gauge, FreeMarker templates are a templates for .ftl suffix, are hereafter referred to as FTL templates, and configuration content includes class name Class, bag name Package, import is imported, qualifier public is accessed, is inherited extends, realizes implements, attribute, method etc..Institute FTL template attributes are stated, including attribute access qualifier, attribute type, Property Name etc..The FTL template methods, including method Access qualifier, method name, method |input paramete, method return type, method concrete function, method note etc..The FTL Template with data, it is necessary to be implemented in combination with final java class output, therefore support data incoming and parsing.Data are with Map key-value pairs Form it is incoming, can incoming Class types, package bags name, property Property Names and attribute type list etc.. FreeMarker will export the expression formula that real value is replaced in braces, referred to as interpolation in the form of " $ { ... } ".
The FTL templates, support FTL grammers label and variable-definition, for the control of FTL template procedures.FTL labels are The instruction of FreeMarker, will not be printed in the output, and the name of these labels is started with #.The FTL labels used in this patent And purposes includes:
(1)<#list>Loop control label, for attribute-list declarations, Getter the and Setter methods of attribute list Definition, attribute list assignment, attribute list output etc..
(2)<#if>Condition abstract factory, judge for attribute type etc..
(3)<#assign>Assignment label, for variable-definition and assignment operation.Variable supports operator operation, but must be <#assign>Carried out in label.
It should be noted that technical solution of the present invention will realize building property value setting using FTL templates and database is inserted Enter with inquiry etc. operation.Because the form of packet is dynamic, comprising data volume and its type be it is indefinite, so if Directly go to call class method by generating the object of java class, each class needs individually to create the object of current class, individually calls Class method, independent incoming supplemental characteristic, furthermore also need to be known a priori by class name before object is created, will all lose the meaning of dynamic operation Justice.
Further, in an example of technical solution of the present invention, the data pattern file is compiled automatically, is used Self-generating, the strategy from compiling, without outside developing instrument or Java compiler directives.When data model class passes through Could be run in JVM, it is necessary to compile after the generation of FreeMarker template engines.
It is described from Compilation Method, it is necessary to incoming by the way of JavaCompiler+CompilationTask in JDK Java source files path and specified Class compiling catalogues, will be in the case where catalogue be compiled according to bag coordinates measurement after compiling successfully Class files.Cause that compilation operations become controllable from compiling, be all dynamic from the whole process for being generated to compilation model data class Realize.
With continued reference to Fig. 1, according to a kind of Database Dynamic generation based on template engine that technical solution of the present invention is provided Method, also includes:
Step S103, class object is created based on the class file, and object type is forced to switch to interface type.
By the way that after step S101 Production databases and database table, technical solution of the present invention takes the plan for realizing interface Slightly, realize that database and database table set up interacting for external data source and the database by the operation of the interface, with complete Storage, inquiry into database and database table etc. are operated, so as to the data for realizing database and database table update.Specifically , a general data operating interface is defined first, data manipulation method is defined in the interface, all properties value is such as set, Data to data storehouse is preserved, according to business operations such as condition query database and returned datas.
The corresponding data class that generates of all packets will realize data operating interface, and make carbon copies data manipulation method, have Body includes below scheme:
(1) data manipulation method is called, is bypassed and is directly generated data class object, object is created by the form for reflecting, so Unsteady state operation is the type of data operating interface afterwards.By the way of polymorphic, the universal method of class itself can be both called, it is more important Can be calling interface method, realize data manipulation, and this process to be entirely dynamic carried out, without reference to specific class Title.
(2) parameter of data manipulation method is incoming, and in order to realize real data unification, incoming parameter is not related to specifically yet Parameter amount, if number of parameters, parameter name and parameter type are indefinite.This patent takes direct incoming byte arrays parameter Form because integer type data (byte, short, int, long and its without character type), real-coded GA (float, Double) and character string type data, mutual conversion is can be achieved between byte arrays.Only need to specified attribute Type and shared byte length, you can realize being obtained from byte arrays the particular content of the attribute, and property value is turned Byte data is turned to be deposited into byte arrays.
With continued reference to Fig. 1, according to a kind of Database Dynamic generation based on template engine that technical solution of the present invention is provided Method, also includes:
Step S104, is built using the operate interface of database described in data model stencil design and according to the interface type The operating method of operate interface described in object reference is found to set up the interaction of external data source and the database.
The operate interface and its interface type defined according to step S103, step S104 have implemented data operating interface And can call the data manipulation method to carry out storage and the inquiry operation of database and database table.Specifically, the data-interface Operating method is called and realizes database purchase and operation, refers to dynamic generation data class object, calls data manipulation method, in full Operated according to assignment, data value, preservation data to data storehouse, from data base querying data etc..
More specifically:
The dynamic generation data class object, as it was noted above, according to Class compiling files path, using the side of reflection Method creates object, and then cast is data operating interface type, and parent universal method and interface are called in polymorphic mode Operating method.
The data assignment operation, refers to all of data in batch setting data class defined in data operating interface Value.In FTL templates, because original data content is present in byte arrays, operating process is needed one by one according to each data volume or attribute Type and length changed in byte stream extraction data actual value, then call correspondence attribute Setter methods it is set Value.
The raw bytes array data, can be the inlet flow of byte stream, or the file reading of network transmission, Can also be the byte arrays for voluntarily generating.
The data value operation, is the inverse process of data assignment defined in data operating interface, is called first Getter methods obtain the actual value of all properties in data class, are then converted and are stored in pre-assigned byte arrays In.
Operated in the preservation data to data storehouse, refer to the pattern number for preserving generation defined in data operating interface According in each data volume of class or attribute to specified database.In FTL templates, substantially one is spliced according to attribute list SQL INSERT sentences.Because the title of attribute is consistent with Database field title, database realizing dynamic operation is preserved.
It is described from data base querying data manipulation, defined in data operating interface, refer to according to search condition, from specify Each field value of data base querying corresponding table, parses and to the attribute assignment of data class.In FTL templates, substantially basis Attribute list has spliced a SQL SELETE sentence, realizes the dynamic operation of inquiry database.
Database Dynamic generation method based on technical solution of the present invention, can dynamically realize data based on template engine The generation in storehouse, storage and inquiry operation, its core concept highlight the mobilism in each operating process.User need to only change and match somebody with somebody Put fileinfo and carry out the input of data source, you can realize database automatically create, data class dynamically generation, on-the-flier compiler with And the flow of data manipulation method dynamic call.The core technology point of technical solution of the present invention includes that profile data parses envelope The dynamic operation of dress, database and table, template engine and its parameter transmission and process control, data operating interface draw with polymorphic With, from compiling and method for reflection, soft coral with operation, finally realize Database Dynamic generation, storage and operating process. It should be noted that the database set up using technical solution of the present invention finally can be interacted only just by with external data source Realize that data storage, inquiry of database and database table etc. are operated, enormously simplify the operating process of database.
Fig. 3 is the algorithm Organization Chart of technical solution of the present invention, and entrance only has two, i.e. profile information and input data Source, outlet is exactly Database Systems.Algorithm parses configuration file, and encapsulation of data information first, on the one hand, data message conduct Property parameters are transmitted to FTL templates, and data class is generated in the presence of template engine;On the other hand, data message is dynamic creation Database and database table provide support.FTL stencil designs realize data operating interface, make carbon copies interface method, and combine attribute Parameter and FTL label process control functions, by FreeMarker template engine generation model data class.Next need to carry out The source file of compiling generation class could run, and using the scheme from compiling, generate Class class files.Then reflex mechanism is passed through Class object is created, and object type is forced to switch to interface type, just can so grasped with the data of polymorphic method call interface Make method, realize to the operation such as the dynamic operation of data model and final dynamic memory, inquiry to database.
Fig. 4 is realized the structure chart example of configuration file by technical solution of the present invention, here using XML form.Configuration text The root node of part is the related configuration information of database, and such as type of database, database server, accounts information, database is compiled Code etc..It is each data packet node, corresponding data model class and database table below root node, comprising title, description, class name etc. Information.It is all of data volume node, the attribute of corresponding data class and the field of database table below data packet node, comprising name The information such as title, description, attribute type, attribute length, attribute default, field type, field default value, field index, annotation.
It should be noted that the numbering of process step is not to execution sequence between step in technical solution of the present invention Limit.
Specific embodiment of the invention is described above.It is to be appreciated that the invention is not limited in above-mentioned Particular implementation, those skilled in the art can within the scope of the claims make various deformations or amendments, this not shadow Sound substance of the invention.

Claims (10)

1. a kind of Database Dynamic generation method based on template engine, it is characterised in that including:
Parse and the configuration information in package arrangements file is to generate data message;
Based on database and database table described in the data message dynamic creation;
The data information transfer is generated into class file to data model template and in the presence of template engine;
Class object is created based on the class file, and object type is forced to switch to interface type;
Object reference institute is set up using the operate interface of database described in data model stencil design and according to the interface type The operating method of operate interface is stated to set up the interaction of external data source and the database.
2. Database Dynamic generation method as claimed in claim 1, it is characterised in that also include:Configure the configuration file; The configuration information at least includes:Database information system, database server information, database accounts information, database draw Hold up information, database coding information, database table name, database table field information.
3. Database Dynamic generation method as claimed in claim 1, it is characterised in that the parsing includes:XML parse or JOSN is parsed.
4. Database Dynamic generation method as claimed in claim 1, it is characterised in that the configuration information refers to the number of generation According to model class and its configuration information of attribute, under the driving of the template engine, configuration information is filled to the data model Template, you can one available data class of generation;
It is described that by the data information transfer to data model template and in the presence of template engine, generation class file includes:It is raw The class file is formed into the data class and by from compiling.
5. Database Dynamic generation method as claimed in claim 4, it is characterised in that described to include from compiling:Using in JDK The mode of JavaCompiler+CompilationTask, it is necessary to incoming Java source files path and specified Class compiling catalogues, After compiling successfully will compile catalogue under according to bag coordinates measurement class file.
6. Database Dynamic generation method as claimed in claim 1, it is characterised in that the configuration information includes database table Configuration information and data model configuration information;The database table configuration information and data model configuration information are to correspond 's.
7. Database Dynamic generation method as claimed in claim 1, it is characterised in that also include:Driven using template engine The data model template, the template engine is FreeMarker template engines.
8. Database Dynamic generation method as claimed in claim 1, it is characterised in that described that class is created based on the class file Object, and object type is forced to switch to interface type and include:
Data manipulation method is called, is bypassed and is directly generated data class object, object is created by the form for reflecting, then force to turn It is changed to the type of data operating interface.
9. Database Dynamic generation method as claimed in claim 1, it is characterised in that described to call data manipulation method at least Including the one kind in following operation:Data assignment, data value, preserve data to data storehouse in, from data base querying data.
10. Database Dynamic generation method as claimed in claim 9, it is characterised in that data assignment operation includes:In data All of data value in batch setting data class defined in operate interface, one by one according to each data volume or the type and length of attribute Changed in byte stream and extract data actual value, then call the Setter methods of correspondence attribute that its value is set;
The operation of data value includes:The inverse process of data assignment, i.e., call Getter side first defined in data operating interface Method obtains the actual value of all properties in data class, is then converted and is stored in pre-assigned byte arrays;
Being operated in preservation data to data storehouse includes:Each data of model data class of generation are preserved defined in data operating interface Amount or attribute have spliced a SQL INSERT sentence in specified database according to attribute list, the title based on attribute with Database field title concord preserves database realizing dynamic operation;
It is included in defined in data operating interface from data base querying data manipulation and is inquired about from specified database according to search condition Each field value of corresponding table, parses and to the attribute assignment of data class, a SQL SELETE language has been spliced according to attribute list Sentence with realize inquire about database dynamic operation.
CN201710045933.6A 2017-01-13 2017-01-13 A kind of Database Dynamic generation method based on template engine Withdrawn CN106844643A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710045933.6A CN106844643A (en) 2017-01-13 2017-01-13 A kind of Database Dynamic generation method based on template engine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710045933.6A CN106844643A (en) 2017-01-13 2017-01-13 A kind of Database Dynamic generation method based on template engine

Publications (1)

Publication Number Publication Date
CN106844643A true CN106844643A (en) 2017-06-13

Family

ID=59119403

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710045933.6A Withdrawn CN106844643A (en) 2017-01-13 2017-01-13 A kind of Database Dynamic generation method based on template engine

Country Status (1)

Country Link
CN (1) CN106844643A (en)

Cited By (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107577498A (en) * 2017-09-21 2018-01-12 山东浪潮商用系统有限公司 One method for automatically generating interface Java resolution files
CN107590007A (en) * 2017-09-22 2018-01-16 北京康爱营养科技股份有限公司 A kind of HIS interface allocation methods based on template engine
CN107608669A (en) * 2017-08-15 2018-01-19 山西云度知识产权服务有限公司 A kind of method based on database table structure automatic generation function and the page
CN107948200A (en) * 2017-12-29 2018-04-20 广州天高软件科技有限公司 A kind of configurable network interface protocols adaptation engine based on source template
CN108170557A (en) * 2018-01-24 2018-06-15 百度在线网络技术(北京)有限公司 For the method and apparatus of output information
CN108845791A (en) * 2018-05-31 2018-11-20 苏州浪潮智能软件有限公司 Application code development process method and device, readable storage medium storing program for executing, terminal
CN108984728A (en) * 2018-07-11 2018-12-11 北京奇艺世纪科技有限公司 A kind of proxy class generation method and device
CN109343804A (en) * 2018-09-28 2019-02-15 江苏中服焦点信息科技有限公司 A kind of method of printing template
CN109815242A (en) * 2019-02-02 2019-05-28 中国农业银行股份有限公司 A kind of data processing method and system
CN110109894A (en) * 2019-03-22 2019-08-09 新奥特(北京)视频技术有限公司 Implementation method, device, storage medium and the equipment of non-relational database
CN110209717A (en) * 2019-04-25 2019-09-06 平安科技(深圳)有限公司 Packaging method, device, computer equipment and the storage medium of basic database
CN110209699A (en) * 2019-05-22 2019-09-06 浙江大学 A kind of data-interface dynamic generation based on openEHR Composition template and execution method
CN110333849A (en) * 2019-05-08 2019-10-15 八戒科技服务有限公司 A kind of method, apparatus for realizing code robot based on FreeMarker template engine
CN110544092A (en) * 2019-08-22 2019-12-06 杭州趣链科技有限公司 Dynamic newly-added multi-type database data operation chaining method for block chain
CN110597504A (en) * 2019-09-20 2019-12-20 北京天地和兴科技有限公司 Rapid generation method of data table codes
CN110795140A (en) * 2019-09-26 2020-02-14 连连银通电子支付有限公司 Configuration file generation method and device
CN110851513A (en) * 2019-10-16 2020-02-28 中盈优创资讯科技有限公司 Multi-source heterogeneous data reading method and device based on Spark calculation engine
CN110888672A (en) * 2019-11-26 2020-03-17 北京仁科互动网络技术有限公司 Metadata architecture-based expression engine implementation method and system
CN111061464A (en) * 2019-11-24 2020-04-24 济南浪潮数据技术有限公司 Analysis code generation method, device, equipment and storage medium
CN111198711A (en) * 2020-01-13 2020-05-26 陕西心像信息科技有限公司 Collection version control method and system based on MongoDB
CN111290748A (en) * 2020-03-11 2020-06-16 福建天晴在线互动科技有限公司 Method for quickly generating SqlServer database operation code
CN111414350A (en) * 2020-03-18 2020-07-14 腾讯科技(深圳)有限公司 Service generation method and device
CN112487163A (en) * 2020-11-30 2021-03-12 广州品唯软件有限公司 Execution method of automation process and acquisition method and device of interface data of automation process
CN112765175A (en) * 2021-01-21 2021-05-07 恒安嘉新(北京)科技股份公司 Interface data processing method and device, computer equipment and medium
CN112905624A (en) * 2021-02-26 2021-06-04 浪潮通用软件有限公司 Database extension method and device of low-code development platform
CN113609138A (en) * 2021-09-30 2021-11-05 成都数联云算科技有限公司 Class and database table matching method, device, equipment and medium
CN113836212A (en) * 2021-09-27 2021-12-24 易保网络技术(上海)有限公司 Method for automatically generating Json data by database data, readable medium and electronic equipment
CN115686459A (en) * 2022-10-31 2023-02-03 北京力控元通科技有限公司 Model generation method, device and equipment based on Java language and readable storage medium
CN116501744A (en) * 2023-06-30 2023-07-28 中国人民解放军国防科技大学 Automatic form building and warehousing method and device for simulation data and computer equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5940834A (en) * 1997-03-13 1999-08-17 Mitel Corporation Automatic web page generator
CN1924907A (en) * 2005-09-02 2007-03-07 鸿富锦精密工业(深圳)有限公司 Network resources automatic management system and method
US20090049064A1 (en) * 2007-08-15 2009-02-19 Lori Alquier Data and application model for configurable tracking and reporting system
CN103699620A (en) * 2013-12-19 2014-04-02 珠海世纪鼎利通信科技股份有限公司 Method and system for achieving database operation by utilizing object relational mapping (ORM) frame in object orientation
CN104717233A (en) * 2013-12-11 2015-06-17 中国电信股份有限公司 Database deployment method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5940834A (en) * 1997-03-13 1999-08-17 Mitel Corporation Automatic web page generator
CN1924907A (en) * 2005-09-02 2007-03-07 鸿富锦精密工业(深圳)有限公司 Network resources automatic management system and method
US20090049064A1 (en) * 2007-08-15 2009-02-19 Lori Alquier Data and application model for configurable tracking and reporting system
CN104717233A (en) * 2013-12-11 2015-06-17 中国电信股份有限公司 Database deployment method and device
CN103699620A (en) * 2013-12-19 2014-04-02 珠海世纪鼎利通信科技股份有限公司 Method and system for achieving database operation by utilizing object relational mapping (ORM) frame in object orientation

Cited By (42)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107608669A (en) * 2017-08-15 2018-01-19 山西云度知识产权服务有限公司 A kind of method based on database table structure automatic generation function and the page
CN107577498A (en) * 2017-09-21 2018-01-12 山东浪潮商用系统有限公司 One method for automatically generating interface Java resolution files
CN107590007A (en) * 2017-09-22 2018-01-16 北京康爱营养科技股份有限公司 A kind of HIS interface allocation methods based on template engine
CN107948200A (en) * 2017-12-29 2018-04-20 广州天高软件科技有限公司 A kind of configurable network interface protocols adaptation engine based on source template
CN108170557A (en) * 2018-01-24 2018-06-15 百度在线网络技术(北京)有限公司 For the method and apparatus of output information
CN108845791A (en) * 2018-05-31 2018-11-20 苏州浪潮智能软件有限公司 Application code development process method and device, readable storage medium storing program for executing, terminal
CN108984728A (en) * 2018-07-11 2018-12-11 北京奇艺世纪科技有限公司 A kind of proxy class generation method and device
CN108984728B (en) * 2018-07-11 2020-11-27 北京奇艺世纪科技有限公司 Proxy class generation method and device
CN109343804A (en) * 2018-09-28 2019-02-15 江苏中服焦点信息科技有限公司 A kind of method of printing template
CN109815242A (en) * 2019-02-02 2019-05-28 中国农业银行股份有限公司 A kind of data processing method and system
CN110109894A (en) * 2019-03-22 2019-08-09 新奥特(北京)视频技术有限公司 Implementation method, device, storage medium and the equipment of non-relational database
CN110209717A (en) * 2019-04-25 2019-09-06 平安科技(深圳)有限公司 Packaging method, device, computer equipment and the storage medium of basic database
CN110209717B (en) * 2019-04-25 2024-01-30 平安科技(深圳)有限公司 Packaging method and device of basic database, computer equipment and storage medium
CN110333849A (en) * 2019-05-08 2019-10-15 八戒科技服务有限公司 A kind of method, apparatus for realizing code robot based on FreeMarker template engine
CN110209699B (en) * 2019-05-22 2021-04-06 浙江大学 Data interface dynamic generation and execution method based on openEHR Composition template
CN110209699A (en) * 2019-05-22 2019-09-06 浙江大学 A kind of data-interface dynamic generation based on openEHR Composition template and execution method
CN110544092B (en) * 2019-08-22 2022-04-01 杭州趣链科技有限公司 Dynamic newly-added multi-type database data operation chaining method for block chain
CN110544092A (en) * 2019-08-22 2019-12-06 杭州趣链科技有限公司 Dynamic newly-added multi-type database data operation chaining method for block chain
CN110597504A (en) * 2019-09-20 2019-12-20 北京天地和兴科技有限公司 Rapid generation method of data table codes
CN110795140A (en) * 2019-09-26 2020-02-14 连连银通电子支付有限公司 Configuration file generation method and device
CN110851513A (en) * 2019-10-16 2020-02-28 中盈优创资讯科技有限公司 Multi-source heterogeneous data reading method and device based on Spark calculation engine
CN110851513B (en) * 2019-10-16 2021-06-08 中盈优创资讯科技有限公司 Multi-source heterogeneous data reading method and device based on Spark calculation engine
CN111061464A (en) * 2019-11-24 2020-04-24 济南浪潮数据技术有限公司 Analysis code generation method, device, equipment and storage medium
CN111061464B (en) * 2019-11-24 2022-04-22 济南浪潮数据技术有限公司 Analysis code generation method, device, equipment and storage medium
CN110888672A (en) * 2019-11-26 2020-03-17 北京仁科互动网络技术有限公司 Metadata architecture-based expression engine implementation method and system
CN111198711B (en) * 2020-01-13 2023-02-28 陕西心像信息科技有限公司 Collection version control method and system based on MongoDB
CN111198711A (en) * 2020-01-13 2020-05-26 陕西心像信息科技有限公司 Collection version control method and system based on MongoDB
CN111290748A (en) * 2020-03-11 2020-06-16 福建天晴在线互动科技有限公司 Method for quickly generating SqlServer database operation code
CN111290748B (en) * 2020-03-11 2023-03-14 福建天晴在线互动科技有限公司 Method for quickly generating SqlServer database operation code
CN111414350A (en) * 2020-03-18 2020-07-14 腾讯科技(深圳)有限公司 Service generation method and device
CN112487163A (en) * 2020-11-30 2021-03-12 广州品唯软件有限公司 Execution method of automation process and acquisition method and device of interface data of automation process
CN112487163B (en) * 2020-11-30 2024-04-12 广州品唯软件有限公司 Execution method of automatic flow and method and device for acquiring interface data of execution method
CN112765175A (en) * 2021-01-21 2021-05-07 恒安嘉新(北京)科技股份公司 Interface data processing method and device, computer equipment and medium
CN112905624A (en) * 2021-02-26 2021-06-04 浪潮通用软件有限公司 Database extension method and device of low-code development platform
CN112905624B (en) * 2021-02-26 2023-01-20 浪潮通用软件有限公司 Database extension method and device of low-code development platform
CN113836212A (en) * 2021-09-27 2021-12-24 易保网络技术(上海)有限公司 Method for automatically generating Json data by database data, readable medium and electronic equipment
CN113836212B (en) * 2021-09-27 2023-09-08 易保网络技术(上海)有限公司 Method for automatically generating Json data by database data, readable medium and electronic equipment
CN113609138B (en) * 2021-09-30 2022-01-25 成都数联云算科技有限公司 Class and database table matching method, device, equipment and medium
CN113609138A (en) * 2021-09-30 2021-11-05 成都数联云算科技有限公司 Class and database table matching method, device, equipment and medium
CN115686459A (en) * 2022-10-31 2023-02-03 北京力控元通科技有限公司 Model generation method, device and equipment based on Java language and readable storage medium
CN116501744B (en) * 2023-06-30 2023-09-19 中国人民解放军国防科技大学 Automatic form building and warehousing method and device for simulation data and computer equipment
CN116501744A (en) * 2023-06-30 2023-07-28 中国人民解放军国防科技大学 Automatic form building and warehousing method and device for simulation data and computer equipment

Similar Documents

Publication Publication Date Title
CN106844643A (en) A kind of Database Dynamic generation method based on template engine
WO2020233367A1 (en) Blockchain data storage and query method, apparatus and device, and storage medium
US7827523B2 (en) Query serving infrastructure providing flexible and expandable support and compiling instructions
US9965259B2 (en) System for translating diverse programming languages
US8286132B2 (en) Comparing and merging structured documents syntactically and semantically
US9086931B2 (en) System for translating diverse programming languages
CN106126540B (en) Data base access system and its access method
US10614126B2 (en) Textual query editor for graph databases that performs semantic analysis using extracted information
KR102294522B1 (en) Parser generation
CN111125440B (en) Monad-based persistent layer composite condition query method and storage medium
US9342555B2 (en) Reporting tools for object-relational databases
CN112235311B (en) OVSDB client code automatic generation method, system, device and medium
CN111880777A (en) Program information issuing method and device and electronic equipment
US8468449B1 (en) Generating CSS shorthand properties
CN109933331A (en) Data transfer device and associated component between a kind of client-server
CN107077496A (en) For indexing system, the method and apparatus that compiling is used with optimum indexing
WO2019068014A1 (en) Enabling data format specific database functionalities over existing data types by marking operand values
WO2018233673A1 (en) Method and apparatus for configuring model code in controller, and storage medium
CN115469881A (en) Configuration publishing and calling method and system for low-code platform service function
CN114115839A (en) ORM code processing method and device, electronic equipment and readable storage medium
US10685021B2 (en) Complete, correct and fast compile-time encoding inference on the basis of an underlying type system
CN109710218A (en) A kind of object automatic switching method and terminal
CN116628066B (en) Data transmission method, device, computer equipment and storage medium
CN108509187B (en) Method and system for automatically generating MIB function code of software platform
CN112486990B (en) Method and equipment for describing synchronous database table structure according to model

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
WW01 Invention patent application withdrawn after publication

Application publication date: 20170613

WW01 Invention patent application withdrawn after publication