CN105159920A - Attribute tag based database access method - Google Patents
Attribute tag based database access method Download PDFInfo
- Publication number
- CN105159920A CN105159920A CN201510451226.8A CN201510451226A CN105159920A CN 105159920 A CN105159920 A CN 105159920A CN 201510451226 A CN201510451226 A CN 201510451226A CN 105159920 A CN105159920 A CN 105159920A
- Authority
- CN
- China
- Prior art keywords
- class
- label
- database
- ado
- sql statement
- 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
- 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/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
Abstract
The invention relates to an attribute tag based database access method, comprising the following steps of: (1) creating user-defined attribute tags; (2) constructing all business classes and adding the user-defined attribute tags in one-to-one correspondence with database content separately; (3) constructing an ADO class of each business class and performing persistent operation; (4) obtaining a database table or a view name and a field name corresponding to the business class through a reflection mechanism; (5) according to the obtained information, creating an SQL statement of CRUD operation; and (6) according to the data information of the specific business class, constructing an SQL parameter object and calling an ADO execution function to realize access to a database. Compared to the prior art, the method has the characteristics that the corresponding user-defined attribute tags are added to the business classes, so that persistent storage of business data is realized and development efficiency is improved; and at the same time, an extra mapping file or mapping relation table is not required to maintain a mapping relation, thereby saving IO and memory resources and improving execution efficiency.
Description
Technical field
The present invention relates to a kind of data bank access method, especially relate to a kind of data bank access method based on attribute tags.
Background technology
Database is the nowadays data administrator that all can use of a lot of supervisory routine, no matter be BS or CS framework applications program, can be divided into data processing and data access two parts, database manipulation is the major part of data access.And the access how carrying out database is in the application the content that a lot of developer is exploring high-efficient simple, two kinds of relatively more conventional modes are modes of object map and obtain Business Entity class relevant information by reflection API, then splice the mode of SQL statement.But two kinds of modes are succinct all not, object map mode needs to map relation between code entity class and database table by xml configuration file, needs to search corresponding relation to determine the object that will operate in a database when carrying out persistence operation.And obtaining Business Entity category information by reflection API, the mode of then splicing SQL statement needs the actual data access class being come mapping object class and this object by pre-configured file, then could perform concrete database manipulation.
Summary of the invention
Object of the present invention is exactly to overcome the defect and a kind of data bank access method based on attribute tags of providing that above-mentioned prior art exists, be intended to realize the binding with database by the attribute tags of service class, thus realize the automatic process of data persistence.
Object of the present invention can be achieved through the following technical solutions:
Based on a data bank access method for attribute tags, it is characterized in that, the method comprises the following steps:
(1) Custom Attributes label is created, comprise the label of self defined class and the label of custom field, the label of described self defined class comprises database table or view name, and the label of described custom field comprises field name and field type in database;
(2) build all service class, and each service class is added respectively and the data-base content label of self defined class and the label of custom field one to one;
(3) build the ADO class of each service class, and carry out persistence operation;
(4) table corresponding to service class or view name and field name is obtained by reflex mechanism;
(5) SQL statement of CRUD operation is built according to the table that gets or view name and field name;
(6) build SQL parameter object according to the data message of concrete service class, call ADO and perform function, if having abnormal, abnormal information returned to system process and close DataBase combining, otherwise return results and close DataBase combining.
The field type of described label is consistent with field type concrete in database.
Described step (3) specifically comprises following sub-step:
(301) the operation template SmrAdoTmplate<T> of ADO class is built;
(302) the ADO class of each service class is built by inheriting SmrAdoTmplate<T> mode;
(302) call ADO class corresponding to service class in systems in which and perform persistence operation.
The concrete mode of SQL statement building CRUD operation in described step (5) is: call the SQL statement that SQL statement splicing SqlServerConvertor class builds CRUD operation.
Described calls the SQL statement that SQL statement splicing SqlServerConvertor class builds CRUD operation, if update, its concrete connecting method is: adopt insertinto{0} ({ 1}) values ({ 2}) character string to operate, table or the view name of described label are formatted to { 0} position, { 1} position is formatted to after the field name of described label is spliced into character string with CSV, before field name, add different prefix according to concrete type of database, splicing SQL statement content of parameter is formatted to { 2} position.
Compared with prior art, the present invention only need add corresponding label substance to service class, can realize the persistent storage of business to data, make development mainly concentrate on the process of service logic, thus improves development efficiency; Mapped the content of Business Entity class and database entity by the attribute tags of class itself, do not need extra mapped file or mapping relations table to safeguard mapping relations, thus save IO and memory source, improve execution efficiency.
Accompanying drawing explanation
Fig. 1 is data bank access method general structure schematic diagram of the present invention;
Fig. 2 is the corresponding relation structural representation of Custom Attributes label of the present invention and database;
Fig. 3 is data bank access method process flow diagram of the present invention.
1 is Business Entity, and 2 is database, and 3 is data persistence layer, and 4 is Custom Attributes label.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in detail.
Embodiment
As Fig. 1, this method realizes the mapping between Business Entity 1 and database 2 entity mainly through Custom Attributes label, carrys out performing database 2 accessing operation by data persistence layer 3.
In Fig. 2, the class name of Custom Attributes label 4 is mapped to database 2 and shows or view name, generic attribute is mapped to field name, therefore Custom Attributes label 4 comprises the label of self defined class and the label of custom field, wherein the label of self defined class only comprises corresponding table or view name, the label of custom field comprises field name and field type in database, and field type should be consistent with concrete field type in database.
Fig. 3 is data bank access method process flow diagram of the present invention, is described in detail below to each step in figure:
In step 301, create Custom Attributes label, comprise the label TableAttribute of self defined class and the label F ieldAttribute of custom field.TableAttribute only defines corresponding table or view name, and whether FieldAttribute define field title also will define outward is major key, performs step 302;
In step 302, build all service class, and each service class is added respectively and the data-base content label of self defined class and the label of custom field one to one, perform step 303;
In step 303, build the operation template SmrAdoTmplate<T> of ADO class, perform step 304;
In step 304, built the ADO class of all service class by the operation template SmrAdoTmplate<T> mode inheriting ADO class, perform step 305;
In step 305, call ADO class corresponding to service class in systems in which and perform persistence operation, perform step 306;
In step 306, service class T is obtained to table name and the field name of its correspondence by reflex mechanism, perform step 307;
In step 307, call SQL statement splicing SqlServerConvertor class, according to the SQL statement that the table name got and field name information architecture CRUD operate, and perform step 308, wherein SQL specifically splices content for update: adopt insertinto{0} ({ 1}) values ({ 2}) character string to carry out update, table name is formatted to { 0} position, field name is formatted to { 1} position after being spliced into character string with CSV, before field, different prefix is added according to concrete type of database, splicing SQL statement content of parameter is formatted to { 2} position,
In step 308, the data message according to concrete T builds SQL parameter object, then calls ADO and performs function, perform step 309;
In step 309, judge that ADO performs function and whether runs succeeded, if successful execution step 311, if unsuccessful, perform step 310;
In step 310, abnormal information is returned to system process, perform step 311;
Step 311, returns results and closes DataBase combining
This data bank access method has been applied in Casco Signal Ltd. iTC product ZC/LC tool software, and the major function of this software carries out processing and changing for the vehicle region control inputted and link control message.
ZC/LC tool software uses C# exploitation, adopts SQL database to complete the storage work of data.
From system development progress, after using this invention, the complexity of programming reduces a lot, and development efficiency has larger lifting; From user's service condition, its interactive mode and response speed have also been obtained extensive accreditation.
Claims (5)
1. based on a data bank access method for attribute tags, it is characterized in that, the method comprises the following steps:
(1) Custom Attributes label is created, comprise the label of self defined class and the label of custom field, the label of described self defined class comprises database table or view name, and the label of described custom field comprises field name and field type in database;
(2) build all service class, and each service class is added respectively and the data-base content label of self defined class and the label of custom field one to one;
(3) build the ADO class of each service class, and carry out persistence operation;
(4) table corresponding to service class or view name and field name is obtained by reflex mechanism;
(5) SQL statement of CRUD operation is built according to the table that gets or view name and field name;
(6) build SQL parameter object according to the data message of concrete service class, call ADO and perform function, if having abnormal, abnormal information returned to system process and close DataBase combining, otherwise return results and close DataBase combining.
2. a kind of data bank access method based on attribute tags according to claim 1, is characterized in that, the field type of described label is consistent with field type concrete in database.
3. a kind of data bank access method based on attribute tags according to claim 2, is characterized in that, described step (3) specifically comprises following sub-step:
(301) the operation template SmrAdoTmplate<T> of ADO class is built;
(302) the ADO class of each service class is built by inheriting SmrAdoTmplate<T> mode;
(302) call ADO class corresponding to service class in systems in which and perform persistence operation.
4. a kind of data bank access method based on attribute tags according to claim 3, it is characterized in that, the concrete mode of SQL statement building CRUD operation in described step (5) is: call the SQL statement that SQL statement splicing SqlServerConvertor class builds CRUD operation.
5. a kind of data bank access method based on attribute tags according to claim 4, it is characterized in that, described calls the SQL statement that SQL statement splicing SqlServerConvertor class builds CRUD operation, if update, its concrete connecting method is: adopt insertinto{0} ({ 1}) values ({ 2}) character string to operate, table or the view name of described label are formatted to { 0} position, { 1} position is formatted to after the field name of described label is spliced into character string with CSV, before field name, different prefix is added according to concrete type of database, splicing SQL statement content of parameter is formatted to { 2} position.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510451226.8A CN105159920A (en) | 2015-07-28 | 2015-07-28 | Attribute tag based database access method |
HK16104660.3A HK1216928A1 (en) | 2015-07-28 | 2016-04-22 | A database access method based on attribute labels |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510451226.8A CN105159920A (en) | 2015-07-28 | 2015-07-28 | Attribute tag based database access method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105159920A true CN105159920A (en) | 2015-12-16 |
Family
ID=54800777
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510451226.8A Pending CN105159920A (en) | 2015-07-28 | 2015-07-28 | Attribute tag based database access method |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN105159920A (en) |
HK (1) | HK1216928A1 (en) |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106354605A (en) * | 2016-09-05 | 2017-01-25 | 上海爱数信息技术股份有限公司 | Database access method and system and server provided with system |
CN107193957A (en) * | 2017-05-23 | 2017-09-22 | 努比亚技术有限公司 | Generation method, terminal and the computer-readable recording medium of SQL |
CN107992293A (en) * | 2017-12-11 | 2018-05-04 | 国云科技股份有限公司 | A kind of enterprise attributes dividing system and its implementation |
CN108268512A (en) * | 2016-12-30 | 2018-07-10 | 中国移动通信集团上海有限公司 | A kind of tag queries method and device |
CN108564304A (en) * | 2018-05-04 | 2018-09-21 | 西北工业大学 | A kind of operation characterising parameter generation method towards aircraft assembly |
CN108628862A (en) * | 2017-03-15 | 2018-10-09 | 北京京东尚科信息技术有限公司 | database addressing method, device and system |
CN108710504A (en) * | 2017-04-10 | 2018-10-26 | 北大方正集团有限公司 | Database operation method and device |
CN110096892A (en) * | 2019-04-29 | 2019-08-06 | 武汉中锐源信息技术开发有限公司 | Database Properties access control method and system |
CN111737225A (en) * | 2020-05-25 | 2020-10-02 | 贵州华泰智远大数据服务有限公司 | Word segmentation technology-based data label database establishment method |
CN111984666A (en) * | 2019-05-23 | 2020-11-24 | 北京数聚鑫云信息技术有限公司 | Database access method and device, computer readable storage medium and computer equipment |
CN112905586A (en) * | 2019-12-03 | 2021-06-04 | 阿里巴巴集团控股有限公司 | Data processing and accessing method, device, computer system and readable storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101067814A (en) * | 2007-05-10 | 2007-11-07 | 浪潮集团山东通用软件有限公司 | Mapping conversion method between data access level Xml format data and relational data |
CN101256650A (en) * | 2008-03-21 | 2008-09-03 | 中国科学院软件研究所 | Method and system for extracting enterprise data based on service entity |
CN101339559A (en) * | 2008-07-18 | 2009-01-07 | 北京航空航天大学 | Long lasting implementing method for data |
CN101706821A (en) * | 2009-12-10 | 2010-05-12 | 中兴通讯股份有限公司 | Tag-based mobile internet page design system and method |
CN101751260A (en) * | 2009-12-23 | 2010-06-23 | 卡斯柯信号有限公司 | Business object persistence processing method based on dynamic labels |
CN102054034A (en) * | 2010-12-27 | 2011-05-11 | 华中科技大学 | Implementation method for business basic data persistence of enterprise information system |
-
2015
- 2015-07-28 CN CN201510451226.8A patent/CN105159920A/en active Pending
-
2016
- 2016-04-22 HK HK16104660.3A patent/HK1216928A1/en unknown
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101067814A (en) * | 2007-05-10 | 2007-11-07 | 浪潮集团山东通用软件有限公司 | Mapping conversion method between data access level Xml format data and relational data |
CN101256650A (en) * | 2008-03-21 | 2008-09-03 | 中国科学院软件研究所 | Method and system for extracting enterprise data based on service entity |
CN101339559A (en) * | 2008-07-18 | 2009-01-07 | 北京航空航天大学 | Long lasting implementing method for data |
CN101706821A (en) * | 2009-12-10 | 2010-05-12 | 中兴通讯股份有限公司 | Tag-based mobile internet page design system and method |
CN101751260A (en) * | 2009-12-23 | 2010-06-23 | 卡斯柯信号有限公司 | Business object persistence processing method based on dynamic labels |
CN102054034A (en) * | 2010-12-27 | 2011-05-11 | 华中科技大学 | Implementation method for business basic data persistence of enterprise information system |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106354605B (en) * | 2016-09-05 | 2019-06-21 | 上海爱数信息技术股份有限公司 | A kind of access method of database, system and the server with the system |
CN106354605A (en) * | 2016-09-05 | 2017-01-25 | 上海爱数信息技术股份有限公司 | Database access method and system and server provided with system |
CN108268512A (en) * | 2016-12-30 | 2018-07-10 | 中国移动通信集团上海有限公司 | A kind of tag queries method and device |
CN108628862A (en) * | 2017-03-15 | 2018-10-09 | 北京京东尚科信息技术有限公司 | database addressing method, device and system |
CN108710504A (en) * | 2017-04-10 | 2018-10-26 | 北大方正集团有限公司 | Database operation method and device |
CN107193957A (en) * | 2017-05-23 | 2017-09-22 | 努比亚技术有限公司 | Generation method, terminal and the computer-readable recording medium of SQL |
CN107992293A (en) * | 2017-12-11 | 2018-05-04 | 国云科技股份有限公司 | A kind of enterprise attributes dividing system and its implementation |
CN108564304A (en) * | 2018-05-04 | 2018-09-21 | 西北工业大学 | A kind of operation characterising parameter generation method towards aircraft assembly |
CN110096892A (en) * | 2019-04-29 | 2019-08-06 | 武汉中锐源信息技术开发有限公司 | Database Properties access control method and system |
CN111984666A (en) * | 2019-05-23 | 2020-11-24 | 北京数聚鑫云信息技术有限公司 | Database access method and device, computer readable storage medium and computer equipment |
CN111984666B (en) * | 2019-05-23 | 2024-03-29 | 北京数聚鑫云信息技术有限公司 | Database access method, apparatus, computer readable storage medium and computer device |
CN112905586A (en) * | 2019-12-03 | 2021-06-04 | 阿里巴巴集团控股有限公司 | Data processing and accessing method, device, computer system and readable storage medium |
CN111737225A (en) * | 2020-05-25 | 2020-10-02 | 贵州华泰智远大数据服务有限公司 | Word segmentation technology-based data label database establishment method |
Also Published As
Publication number | Publication date |
---|---|
HK1216928A1 (en) | 2016-12-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105159920A (en) | Attribute tag based database access method | |
CN107273286B (en) | Scene automatic test platform and method for task application | |
CN106874388B (en) | Relational database-based heterogeneous system data cascade operation automatic construction method | |
US8392873B2 (en) | Methods and apparatus for implementing model-based software solution development and integrated change management | |
CN109670053B (en) | Data object mapping method, device, equipment and computer readable storage medium | |
US20150365275A1 (en) | Cloud environment configuration for cloud applications | |
CN104407863A (en) | Abstract control model programming device and method | |
US20120324421A1 (en) | Application creation tool toolkit | |
CN111399828B (en) | Model-driven logic device modeling method and terminal | |
US9509560B2 (en) | Unified configuration for cloud integration | |
CN103268226A (en) | Test script file generation method and device | |
CN113050946A (en) | Method and device for generating website application system, electronic equipment and storage medium | |
CN109710220A (en) | Relevant database querying method, device, equipment and storage medium | |
CN111666100B (en) | Software framework generation method and device, electronic equipment and storage medium | |
CN104699748A (en) | Method and system for showing report form with non-fixed column numbers | |
US20200394055A1 (en) | System and method for providing a configurable user interface using a self-describing data system | |
CN109960709B (en) | Database driver processing method, device, equipment and storage medium | |
CN111581183A (en) | Data migration method and device based on data model | |
CN114647416A (en) | Method and device for realizing service flow based on annotation, storage medium and electronic equipment | |
CN110851123A (en) | WebGIS power grid visualization framework construction method, system and device based on SpringMVC | |
CN112256355B (en) | Data-driven system function loading method, equipment and storage medium | |
CN112604273B (en) | Data-driven game system function loading method, device and storage medium | |
US20130127863A1 (en) | Determining an optimal sequence of status transitions for business objects | |
CN102541544A (en) | Method, device and system for processing tree control | |
CN115115062B (en) | Machine learning model building method, related device and computer program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
REG | Reference to a national code |
Ref country code: HK Ref legal event code: DE Ref document number: 1216928 Country of ref document: HK |
|
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20151216 |
|
RJ01 | Rejection of invention patent application after publication | ||
REG | Reference to a national code |
Ref country code: HK Ref legal event code: WD Ref document number: 1216928 Country of ref document: HK |