CN105677323A - Method for automatically generating database operation layer codes - Google Patents
Method for automatically generating database operation layer codes Download PDFInfo
- Publication number
- CN105677323A CN105677323A CN201511013779.1A CN201511013779A CN105677323A CN 105677323 A CN105677323 A CN 105677323A CN 201511013779 A CN201511013779 A CN 201511013779A CN 105677323 A CN105677323 A CN 105677323A
- Authority
- CN
- China
- Prior art keywords
- code
- database
- entity class
- field
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/316—Aspect-oriented programming techniques
Abstract
The invention provides a method for automatically generating database operation layer codes. The method comprises: based on configuration file information, connecting a database; acquiring all the data tables of the database, and reading key information from the data tables; and applying a preset entity type code programming template, converting and defining the read key information, and generating corresponding entity type codes. The method of the invention can be adaptive to all the current mainstream databases and programming languages, and contain database operation layer functions of current mainstream development. In spite of the amount of the data tables, the application of the preset entity type code programming template can automatically generate entity type codes, which saves development time, is easy to modify, and prevents occurrence of errors that programmers may have in codes editing.
Description
Technical field
The present invention relates to the object-oriented programming technical field based on database manipulation, specifically the method for a kind of automatically generated data storehouse operation layer code.
Background technology
During Object-oriented Programming Design, programmer is required for different data base's configurations and carrys out the relatively-stationary program code of compiling form, and when data base converts, need to remove amendment code one by one, and it is possible that various mistake in the process write and revise, greatly waste the time of programmer, affect development efficiency.
For different data bases, the literary style of its operation layer code is often also different, and for different business demands, it is desirable to have the mode of changing is looked in different additions and deletions, therefore has substantial amounts of redundant code and generates. More existing database-operation level code generating method is integrated and encapsulation to a certain extent, and for centralized database or programming language, function is simple.
Summary of the invention
The method that it is an object of the invention to provide a kind of automatically generated data storehouse operation layer code, the method can based on the data base of current main flow, for different programming languages and multiple different system, automatically generated data storehouse operation layer code.
The technical scheme is that
The method of a kind of automatically generated data storehouse operation layer code, comprises the following steps:
(1) according to profile information, data base is connected;
(2) obtaining all tables of data of data base, read key message from tables of data, described key message includes table name, field name, field type, field size and major key;
(3) apply mechanically entity class code programming template set in advance, the key message of reading is carried out conversion operation and defining operation, generates corresponding entity class code;
Described conversion operation includes that table name is converted to entity class name, field name is converted to entity class attribute, field type is converted to attribute type; Described defining operation includes according to field size and major key, definition application memory space and definition field non-NULL;
(4) the entity class code information according to type of database and generation, applies mechanically database-operation level code programming template set in advance, generates database manipulation layer identification code.
The method of described automatically generated data storehouse operation layer code, further comprising the steps of:
In described database-operation level code programming template, the entity class attribute in entity class code information and multiple operating condition are set up mapping relations, generates the database manipulation layer identification code of the extension corresponding with multiple operating condition.
The method of described automatically generated data storehouse operation layer code, further comprising the steps of:
In described database-operation level code programming template, the pre-defined return Value Types that be there is a need to use, return Value Types for every kind of database-operation level Code automatic build.
The described method automatically generating entity class code, in step (2), the described all tables of data obtaining data base, specifically adopt bounce technique.
The invention have the benefit that
As shown from the above technical solution, the present invention can the current all Sybases of self adaptation and programming language, contain the database manipulation layer function in the exploitation of current main flow, no matter tables of data amount is how many, by applying mechanically database-operation level code programming template set in advance, it is possible to automatically generated data storehouse operation layer code, save the development time, and it is easily modified, it is to avoid programmer's mistake generation in the Code Edit.
Accompanying drawing explanation
Fig. 1 is the method flow diagram of the present invention;
Fig. 2 is the product process figure of entity class code in the present invention.
Detailed description of the invention
The present invention is further illustrated below in conjunction with the drawings and specific embodiments.
As shown in Figure 1 and Figure 2, the method for a kind of automatically generated data storehouse operation layer code, comprise the following steps:
S1, according to configuration file, building database connects;
Configuration file contains data base's (type of database, IP, Instance Name, user name, password etc.), programming language information, for disparate databases, different programming language, adopts corresponding method to connect data base.
Key message in S2, all tables of data adopting bounce technique acquisition data base and tables of data, key message includes table name, field name, field type, field size, major key etc.
S3, applying mechanically entity class code programming template set in advance, the database information according to obtaining automatically generates corresponding entity class code;
For different programming languages and disparate databases, carry out the conversion of correspondence, basic corresponding relation:
Table name entity class name, field name entity class attribute, field type attribute type, and according to the information such as field size and major key, definition application memory space, definition field non-NULL etc.
In aforesaid operations, according to different exploitation demands, can freely customize form and the attribute templates of entity class code, convenient programming afterwards use.
S4, preliminary setting data storehouse operation layer code programming template, this template definition kind of operation layer code (such as increase, delete, look into, change, sort, paging query, Connection inquiring, by Field Inquiry, delete by field, revise by field), return Value Types (such as data acquisition system, single field data value, record number, list set) etc.
S5, entity class code information according to type of database and generation, apply mechanically database-operation level code programming template set in advance, generates basic increasing, deletes, looks into, changes code.
Each entity class generates a set of increasing, deletes, looks into, changes code, it is possible to use the operation to entity class, completes the operation of the tables of data that this entity class is corresponding.
Increase: add one or more record;Delete: delete one or more record; Look into: the inquiry all records of corresponding data table; Change: revise one or more record.
S6, in database-operation level code programming template, entity class attribute in entity class code information and multiple operating condition are set up mapping relations, generate the operation layer code of the extension corresponding with multiple operating condition, for instance paging query, sequence, Connection inquiring, by Field Inquiry, delete by field, by field amendment or other have the operation layer code of demand.
Operating condition can be divided into following a few class substantially: the text field and follow-up input operation content mate completely (as name=so-and-so), the text field fuzzy matching, numeric type field relatively or operation (more than, less than, equal to, summation etc.).
Every kind of operation layer code is because type difference understands corresponding different number of parameters, and parameter can give expression to corresponding operating condition, operation field, field number etc.
S7, preset the return Value Types that be there is a need to use, return Value Types for every kind of operation layer Code automatic build.
The present invention based on the data base of current main flow, such as Oracle, Sqlserver, MySQL, Access etc., for different programming languages, such as JAVA, C# etc., can can use for multiple different system, such as Windows, Android etc. Except ' increasing ' basic for each tables of data of data base, ' deleting ', ' looking into ', outside ' changing ' function, substantially possess all functions of current database-operation level, such as the inquiry (inquiry of single field or multiple field; Paging query; Fuzzy query; Conjunctive query); Delete, revise (the deletion amendments under various conditions); Return data (record number, data acquisition system, field value etc.).
Present invention can be suitably applied to based on, in the Object-oriented Programming Design of data base, can automatically generating entity class code and be placed under fixing file, can use in lead-in item before the project of writing, detailed process is as follows:
A, fill in configuration file, config.xml, the programming language of configuration database method of attachment and use;
B, editing template, make the entity class code of generation meet individual or project demand style;
C, running tool, generate entity class code, is saved under corresponding document folder, is generally defaulted as entity;
D, generation database manipulation layer identification code, be saved under corresponding document folder, be generally defaulted as DAL;
E, entity is imported programming tool, can use in the project of VS, eclipse.
The above embodiment is only that the preferred embodiment of the present invention is described; not the scope of the present invention is defined; under the premise designing spirit without departing from the present invention; various deformation that technical scheme is made by those of ordinary skill in the art and improvement, all should fall in the protection domain that claims of the present invention are determined.
Claims (4)
1. the method for an automatically generated data storehouse operation layer code, it is characterised in that comprise the following steps:
(1) according to profile information, data base is connected;
(2) obtaining all tables of data of data base, read key message from tables of data, described key message includes table name, field name, field type, field size and major key;
(3) apply mechanically entity class code programming template set in advance, the key message of reading is carried out conversion operation and defining operation, generates corresponding entity class code;
Described conversion operation includes that table name is converted to entity class name, field name is converted to entity class attribute, field type is converted to attribute type;Described defining operation includes according to field size and major key, definition application memory space and definition field non-NULL;
(4) the entity class code information according to type of database and generation, applies mechanically database-operation level code programming template set in advance, generates database manipulation layer identification code.
2. the method for automatically generated data storehouse according to claim 1 operation layer code, it is characterised in that further comprising the steps of:
In described database-operation level code programming template, the entity class attribute in entity class code information and multiple operating condition are set up mapping relations, generates the database manipulation layer identification code of the extension corresponding with multiple operating condition.
3. the method for automatically generated data storehouse according to claim 1 operation layer code, it is characterised in that further comprising the steps of:
In described database-operation level code programming template, the pre-defined return Value Types that be there is a need to use, return Value Types for every kind of database-operation level Code automatic build.
4. the method automatically generating entity class code according to claim 1, it is characterised in that in step (2), the described all tables of data obtaining data base, specifically adopt bounce technique.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511013779.1A CN105677323A (en) | 2015-12-31 | 2015-12-31 | Method for automatically generating database operation layer codes |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511013779.1A CN105677323A (en) | 2015-12-31 | 2015-12-31 | Method for automatically generating database operation layer codes |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105677323A true CN105677323A (en) | 2016-06-15 |
Family
ID=56297796
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201511013779.1A Pending CN105677323A (en) | 2015-12-31 | 2015-12-31 | Method for automatically generating database operation layer codes |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105677323A (en) |
Cited By (26)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106293727A (en) * | 2016-08-04 | 2017-01-04 | 深圳市微我科技有限公司 | A kind of method of shared wisdom based on tables of data |
CN106446182A (en) * | 2016-09-29 | 2017-02-22 | 贵州云众知乐教育科技有限公司 | Database engine |
CN106648645A (en) * | 2016-12-13 | 2017-05-10 | 北京护航科技股份有限公司 | Code generating system |
CN107391153A (en) * | 2017-07-31 | 2017-11-24 | 深圳乐信软件技术有限公司 | A kind of code generating method and device based on Spring Yu MyBatis framework integrations |
CN107577818A (en) * | 2017-09-30 | 2018-01-12 | 北京酷我科技有限公司 | A kind of method caused by database object placement model |
CN108052549A (en) * | 2017-11-27 | 2018-05-18 | 中山路得斯空调有限公司 | A kind of method that source data is automatically converted to entity category code |
CN108446398A (en) * | 2018-03-27 | 2018-08-24 | 北京邦邦共赢网络科技有限公司 | A kind of generation method and device of database |
CN108509199A (en) * | 2018-03-09 | 2018-09-07 | 平安科技(深圳)有限公司 | Automatically generate the method, apparatus, equipment and storage medium of Chinese annotation |
CN108595162A (en) * | 2018-03-20 | 2018-09-28 | 北京车音网科技有限公司 | A kind of code generating method and device |
CN109240661A (en) * | 2018-08-02 | 2019-01-18 | 武汉烽火众智数字技术有限责任公司 | A kind of code generating method and device |
CN109542453A (en) * | 2018-11-20 | 2019-03-29 | 北京千丁互联科技有限公司 | Database information recognition methods, device and terminal |
CN109542428A (en) * | 2018-10-16 | 2019-03-29 | 平安普惠企业管理有限公司 | Method for processing business, device, computer equipment and storage medium |
CN109725893A (en) * | 2018-05-17 | 2019-05-07 | 平安普惠企业管理有限公司 | Code generating method, unit and computer readable storage medium |
CN110531971A (en) * | 2019-08-29 | 2019-12-03 | 深圳市今天国际物流技术股份有限公司 | Fetcher code automatic generation method, device, computer equipment and storage medium |
CN110837363A (en) * | 2019-11-05 | 2020-02-25 | 北京锐安科技有限公司 | Code file generation method, device, equipment and medium |
CN111061475A (en) * | 2019-12-13 | 2020-04-24 | 中国南方电网有限责任公司 | Software code generation method and device, computer equipment and storage medium |
CN111078761A (en) * | 2019-12-27 | 2020-04-28 | 天津幸福生命科技有限公司 | Data probing method, device, equipment and storage medium |
CN111078205A (en) * | 2019-11-22 | 2020-04-28 | 北京锐安科技有限公司 | Modular programming method and device, storage medium and electronic equipment |
CN111078213A (en) * | 2018-10-18 | 2020-04-28 | 马上消费金融股份有限公司 | Code generation method and code generation device |
CN111290748A (en) * | 2020-03-11 | 2020-06-16 | 福建天晴在线互动科技有限公司 | Method for quickly generating SqlServer database operation code |
CN111796810A (en) * | 2020-07-03 | 2020-10-20 | 福建天晴在线互动科技有限公司 | Method and system for configurable rapid generation of Mysql database codes |
CN111966741A (en) * | 2020-09-04 | 2020-11-20 | 华夏天信(北京)智能低碳技术研究院有限公司 | Data generation method for mine holographic one-image spatial database |
CN112711405A (en) * | 2020-12-28 | 2021-04-27 | 山东浪潮通软信息科技有限公司 | Method, equipment and storage medium for generating add-delete-modify-check application program interface |
CN113190218A (en) * | 2021-04-28 | 2021-07-30 | 中国邮政储蓄银行股份有限公司 | Target operation function generation method and device |
CN113535141A (en) * | 2020-04-16 | 2021-10-22 | 浙江大搜车软件技术有限公司 | Database operation code generation method and device |
CN114089976A (en) * | 2022-01-21 | 2022-02-25 | 通联支付网络服务股份有限公司 | Method, apparatus, and medium for generating database operation statements |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102663103A (en) * | 2012-04-13 | 2012-09-12 | 北京工业大学 | Configurable method for automatically generating database and accessing data |
CN103226478A (en) * | 2013-05-22 | 2013-07-31 | 北京金和软件股份有限公司 | Method for automatically generating and using code |
CN104834551A (en) * | 2015-04-30 | 2015-08-12 | 南京工业大学 | .NET code automatic generating method based on four-layer framework |
-
2015
- 2015-12-31 CN CN201511013779.1A patent/CN105677323A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102663103A (en) * | 2012-04-13 | 2012-09-12 | 北京工业大学 | Configurable method for automatically generating database and accessing data |
CN103226478A (en) * | 2013-05-22 | 2013-07-31 | 北京金和软件股份有限公司 | Method for automatically generating and using code |
CN104834551A (en) * | 2015-04-30 | 2015-08-12 | 南京工业大学 | .NET code automatic generating method based on four-layer framework |
Cited By (37)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106293727B (en) * | 2016-08-04 | 2020-10-27 | 深圳市微我科技有限公司 | Data table-based intelligent sharing method |
CN106293727A (en) * | 2016-08-04 | 2017-01-04 | 深圳市微我科技有限公司 | A kind of method of shared wisdom based on tables of data |
CN106446182A (en) * | 2016-09-29 | 2017-02-22 | 贵州云众知乐教育科技有限公司 | Database engine |
CN106648645A (en) * | 2016-12-13 | 2017-05-10 | 北京护航科技股份有限公司 | Code generating system |
CN107391153B (en) * | 2017-07-31 | 2020-10-16 | 深圳乐信软件技术有限公司 | Code generation method and device based on Spring and MyBatis framework integration |
CN107391153A (en) * | 2017-07-31 | 2017-11-24 | 深圳乐信软件技术有限公司 | A kind of code generating method and device based on Spring Yu MyBatis framework integrations |
CN107577818A (en) * | 2017-09-30 | 2018-01-12 | 北京酷我科技有限公司 | A kind of method caused by database object placement model |
CN108052549A (en) * | 2017-11-27 | 2018-05-18 | 中山路得斯空调有限公司 | A kind of method that source data is automatically converted to entity category code |
CN108509199A (en) * | 2018-03-09 | 2018-09-07 | 平安科技(深圳)有限公司 | Automatically generate the method, apparatus, equipment and storage medium of Chinese annotation |
CN108595162B (en) * | 2018-03-20 | 2022-04-05 | 北京车音网科技有限公司 | Code generation method and device |
CN108595162A (en) * | 2018-03-20 | 2018-09-28 | 北京车音网科技有限公司 | A kind of code generating method and device |
CN108446398A (en) * | 2018-03-27 | 2018-08-24 | 北京邦邦共赢网络科技有限公司 | A kind of generation method and device of database |
CN109725893A (en) * | 2018-05-17 | 2019-05-07 | 平安普惠企业管理有限公司 | Code generating method, unit and computer readable storage medium |
CN109240661B (en) * | 2018-08-02 | 2022-01-21 | 武汉烽火众智数字技术有限责任公司 | Code generation method and device |
CN109240661A (en) * | 2018-08-02 | 2019-01-18 | 武汉烽火众智数字技术有限责任公司 | A kind of code generating method and device |
CN109542428A (en) * | 2018-10-16 | 2019-03-29 | 平安普惠企业管理有限公司 | Method for processing business, device, computer equipment and storage medium |
CN111078213B (en) * | 2018-10-18 | 2024-01-19 | 马上消费金融股份有限公司 | Code generation method and code generation device |
CN111078213A (en) * | 2018-10-18 | 2020-04-28 | 马上消费金融股份有限公司 | Code generation method and code generation device |
CN109542453A (en) * | 2018-11-20 | 2019-03-29 | 北京千丁互联科技有限公司 | Database information recognition methods, device and terminal |
CN110531971A (en) * | 2019-08-29 | 2019-12-03 | 深圳市今天国际物流技术股份有限公司 | Fetcher code automatic generation method, device, computer equipment and storage medium |
CN110531971B (en) * | 2019-08-29 | 2023-01-03 | 深圳市今天国际物流技术股份有限公司 | Automatic generation method and device of access code, computer equipment and storage medium |
CN110837363A (en) * | 2019-11-05 | 2020-02-25 | 北京锐安科技有限公司 | Code file generation method, device, equipment and medium |
CN111078205B (en) * | 2019-11-22 | 2024-01-26 | 北京锐安科技有限公司 | Modularized programming method and device, storage medium and electronic equipment |
CN111078205A (en) * | 2019-11-22 | 2020-04-28 | 北京锐安科技有限公司 | Modular programming method and device, storage medium and electronic equipment |
CN111061475B (en) * | 2019-12-13 | 2023-12-12 | 中国南方电网有限责任公司 | Software code generating method, device, computer equipment and storage medium |
CN111061475A (en) * | 2019-12-13 | 2020-04-24 | 中国南方电网有限责任公司 | Software code generation method and device, computer equipment and storage medium |
CN111078761A (en) * | 2019-12-27 | 2020-04-28 | 天津幸福生命科技有限公司 | Data probing method, device, equipment and storage medium |
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 |
CN113535141A (en) * | 2020-04-16 | 2021-10-22 | 浙江大搜车软件技术有限公司 | Database operation code generation method and device |
CN111796810A (en) * | 2020-07-03 | 2020-10-20 | 福建天晴在线互动科技有限公司 | Method and system for configurable rapid generation of Mysql database codes |
CN111966741B (en) * | 2020-09-04 | 2023-10-13 | 华夏天信物联科技有限公司 | Data generation method for mine holographic one-image space database |
CN111966741A (en) * | 2020-09-04 | 2020-11-20 | 华夏天信(北京)智能低碳技术研究院有限公司 | Data generation method for mine holographic one-image spatial database |
CN112711405A (en) * | 2020-12-28 | 2021-04-27 | 山东浪潮通软信息科技有限公司 | Method, equipment and storage medium for generating add-delete-modify-check application program interface |
CN113190218A (en) * | 2021-04-28 | 2021-07-30 | 中国邮政储蓄银行股份有限公司 | Target operation function generation method and device |
CN114089976A (en) * | 2022-01-21 | 2022-02-25 | 通联支付网络服务股份有限公司 | Method, apparatus, and medium for generating database operation statements |
CN114089976B (en) * | 2022-01-21 | 2022-04-26 | 通联支付网络服务股份有限公司 | Method, apparatus, and medium for generating database operation statements |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105677323A (en) | Method for automatically generating database operation layer codes | |
CN105677324A (en) | Method for automatically generating entity type codes | |
CN104133772A (en) | Automatic test data generation method | |
CN108052681A (en) | The synchronous method and system of structural data between a kind of relevant database | |
CN111026777B (en) | Entity class code generation method, entity class code generation device, computer equipment and storage medium | |
CN105138501A (en) | Configurable dynamic report generating method and system | |
CN105224377A (en) | A kind of method by metadata automatic generating software project code file and device | |
CN106528129A (en) | Web application interface generation system and method | |
US20120290620A1 (en) | Query Template Definition and Transformation | |
CN105447122A (en) | Implementation method for autonomously creating file system based on multi-table association | |
CN105022615A (en) | Interface generating method and system | |
CN103593443A (en) | Method for electronic file metadata expansion | |
CN103049251B (en) | A kind of data base persistence layer device and database operation method | |
US20170193036A1 (en) | Framework for joining datasets | |
CN103412868A (en) | Method and device for generating document | |
CN102819609A (en) | Modeling method for persisting data model | |
EP1755050A1 (en) | A data processing system and method of storing a dataset having a hierarchical data structure in a database | |
CN110750553A (en) | Method for self-defining export of data in service management system | |
CN111290748B (en) | Method for quickly generating SqlServer database operation code | |
CN105573774A (en) | Application parameter managing and configuring method | |
WO2018233673A1 (en) | Method and apparatus for configuring model code in controller, and storage medium | |
US8707260B2 (en) | Resolving interdependencies between heterogeneous artifacts in a software system | |
CN105468793A (en) | Automated management method for simulation model data | |
CN110889272A (en) | Data processing method, device, equipment and storage medium | |
JP2014504469A (en) | Network element configuration management |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20160615 |
|
RJ01 | Rejection of invention patent application after publication |