CN107577818A - A kind of method caused by database object placement model - Google Patents

A kind of method caused by database object placement model Download PDF

Info

Publication number
CN107577818A
CN107577818A CN201710912806.1A CN201710912806A CN107577818A CN 107577818 A CN107577818 A CN 107577818A CN 201710912806 A CN201710912806 A CN 201710912806A CN 107577818 A CN107577818 A CN 107577818A
Authority
CN
China
Prior art keywords
database
type
placement model
attribute
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
Application number
CN201710912806.1A
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.)
Beijing Kuwo Technology Co Ltd
Original Assignee
Beijing Kuwo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kuwo Technology Co Ltd filed Critical Beijing Kuwo Technology Co Ltd
Priority to CN201710912806.1A priority Critical patent/CN107577818A/en
Publication of CN107577818A publication Critical patent/CN107577818A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention relates to a kind of method caused by database object placement model, comprise the following steps:Receive the input object that user sends, the attribute of input object is read in real time, and according to preset protocol is read, input object and its attribute are changed, Basis of Database object placement model is produced, database object placement model is further produced on the basis of Basis of Database object placement model.The present invention, by the model, realize SQL statement encapsulation and parsing, reduce code when accessing database writes work, improves development efficiency, avoid the duplication of labour accumulate caused by mistake.

Description

A kind of method caused by database object placement model
Technical field
The present invention relates to database technical field, method caused by specifically a kind of database object placement model.
Background technology
With the development of database technology, various demands continuously emerge, and constantly supervise further technological innovation, rise Level.In program development, programmer runs into following situation sometimes:
When company goes to work, the sometimes work on daytime does not finish, and programmer will take work home overtime work at night and continue to do.But It is that company is typically entity data bak with database for the supporting exploitation of program development, is deployed on development support server , the development support server is a server inside corporate lan, and service end normal operation is dependent on exploitation branch Hold the exploitation database on server.Due to being in, overtime work can not be accessed inside corporate lan, therefore cannot be connected Exploitation database on upper development support server, this results in service end cisco unity malfunction, function during program development It can not just debug.
In the prior art, a kind of solution method is exactly to use virtual data base.Just the use of company is journey when company goes to work Sequence develops supporting exploitation database;Go back home, just use the virtual data base analog development database in internal memory, do one A little basic function debuggings, are definitely generally enough.
Need largely to localize storage service in current app.In order to meet current business demand, we need in app Data base tool is largely used, it is contemplated that allowing the convenient exploitation of programmer.
Entity data bak, which reads data, needs following steps:
1st, connected with Database,
2nd, SQL query statement is write,
3rd, query statement is performed,
4th, Query Result is obtained,
5th, database is closed.
Obviously, today of frequent reading/data storage is frequently interacted, needed with database in needs, accesses data The workload in storehouse is very big, programmer it is cumbersome write SQL statement, not only workload is big, and easily causes to malfunction, it is necessary to This further is reasonably optimized.
The content of the invention
For defect present in prior art, it is an object of the invention to provide a kind of production of database object placement model Raw method, by the model, SQL statement encapsulation and parsing are realized, code writes work, raising when reducing access database Development efficiency, avoid mistake caused by duplication of labour accumulation.
To achieve the above objectives, the present invention adopts the technical scheme that:
A kind of method caused by database object placement model, it is characterised in that comprise the following steps:
The input object that user sends is received,
The attribute of input object is read in real time,
According to preset protocol is read, input object and its attribute are changed, produce Basis of Database object placement model,
Database object placement model is further produced on the basis of Basis of Database object placement model,
Wherein:
Function when passing through system operation:Class_copyPropertyList () obtains generic attribute relevant information array,
Function when passing through operation:Property_getAttributes () obtains respective attributes information,
Corresponding information is obtained with reference to table by comparison system type,
Object type resolver is coordinated to parse the type of each data, the information being then mapped in database, including number According to information such as storehouse type, database default value, database default sizes,
Function property_getName () is parsed in object during with reference to operation, the Key values corresponding to this type attribute, so Afterwards data value corresponding to type is obtained using KeyValue.
On the basis of above-mentioned technical proposal, following processing are carried out successively to input object and its attribute, produce object class Type and type of database corresponding table:
Type conversion process is carried out to input object and its attribute,
Object type conversion process is carried out to input object and its attribute,
Type of database conversion process is carried out to input object and its attribute.
On the basis of above-mentioned technical proposal, by preset protocol, from input object and its attribute, following letter is parsed Breath:
Data default value,
Data default size,
Major key,
Data non-NULL limits.
On the basis of above-mentioned technical proposal, by obtained object type and type of database corresponding table, data default value, Data default size, major key, the limitation of data non-NULL are integrated, and obtain Basis of Database object placement model.
On the basis of above-mentioned technical proposal, by preset protocol, from input object and its attribute, following letter is parsed Breath:
Data storage value,
Table name,
Database upgrade reminder flag position,
Database special field handles flag bit.
On the basis of above-mentioned technical proposal, Basis of Database object placement model, data storage value, the table name that will obtain Title, database upgrade reminder flag position, database special field processing flag bit are integrated, and obtain database object placement model.
Method caused by database object placement model of the present invention, by the model, realize SQL statement encapsulation and Parsing, reduce code when accessing database writes work, improves development efficiency, avoid the duplication of labour accumulate caused by mistake.
Brief description of the drawings
The present invention has drawings described below:
The FB(flow block) of Fig. 1 present invention.
Embodiment
The present invention is described in further detail below in conjunction with accompanying drawing.
As shown in figure 1, method caused by database object placement model of the present invention, comprises the following steps:
The input object that user sends is received,
In real time(Runtime)Reading input object attribute,
According to preset protocol is read, input object and its attribute are changed, produce Basis of Database object placement model,
Database object placement model is further produced on the basis of Basis of Database object placement model.
On the basis of above-mentioned technical proposal, following processing are carried out successively to input object and its attribute, produce object class Type and type of database corresponding table:
Type conversion process is carried out to input object and its attribute,
Object type conversion process is carried out to input object and its attribute,
Type of database conversion process is carried out to input object and its attribute.
On the basis of above-mentioned technical proposal, by preset protocol, from input object and its attribute, following letter is parsed Breath:
Data default value,
Data default size,
Major key,
Data non-NULL limits.
On the basis of above-mentioned technical proposal, by obtained object type and type of database corresponding table, data default value, Data default size, major key, the limitation of data non-NULL are integrated, and obtain Basis of Database object placement model.
On the basis of above-mentioned technical proposal, by preset protocol, from input object and its attribute, following letter is parsed Breath:
Data storage value,
Table name,
Database upgrade reminder flag position,
Database special field handles flag bit.
Function when passing through system operation first:Class_copyPropertyList () obtains generic attribute relevant information number Group, function when passing through operation:Property_getAttributes () obtains respective attributes information.
It can be obtained such as by property_getAttributes () function:Tq,D,N;T@”NSNumber”,&,D,N;This The attribute information of class, corresponding information is obtained with reference to table by comparison system type.Such as q represent herein be NSInteger types etc..
objc_property_t * propertes = class_copyPropertyList(clazz, & propertesCount);
const char * attributesChar = property_getAttributes(propertes[i]);
NSString * propertyStr = [NSString stringWithCString:propertyChar
encoding:NSUTF8StringEncoding];
Then we need predefined map field:
NSString * const kSqlStoreNamed = @"sql_store_name";
NSString * const kSqlStoreValue = @"sql_store_value";
NSString * const kSqlStoreType = @"sql_store_type";
NSString * const kSqlStoreSize = @"sql_store_size";
NSString * const kSqlStorePrimaryKey = @"sql_store_primaryKey";
NSString * const kSqlStoreUnique = @"sql_store_unique";
NSString * const kSqlStoreNotNull = @"sql_store_notNull";
NSString * const kSqlTableNamed = @"sql_table_name";
NSString * const kSqlStoreDefaultValue = @"sql_store_default_value";
NSString * const kSqlStoreAutoIncrement = @"sql_store_autoIncrement";
This cooperation object type resolver is parsed to the type of each data, the information being then mapped in database, bag Include the information such as type of database, database default value, database default size.
Function property_getName () is parsed in object during with reference to operation, the Key corresponding to this type attribute Value, then obtains data value corresponding to type using KeyValue:
const char * propertyChar = property_getName(propertes[i]);
id value = [instanceObject valueForKey:propertyStr];
By above-mentioned steps, basic mapping algorithm is finally drawn:
- (void)mappedDataModelArrayWithClass:(Class)clazz
instanceObject:(id)instanceObject {
unsigned int propertesCount = 0;
objc_property_t * propertes = class_copyPropertyList(clazz, & propertesCount);
for (int i = 0 ; i < propertesCount ; i++) {
const char * propertyChar = property_getName(propertes[i]);
const char * attributesChar = property_getAttributes(propertes [i]);
NSString * propertyStr = [NSString stringWithCString: propertyChar
encoding: NSUTF8StringEncoding];
id value = [instanceObject valueForKey: propertyStr];
VTypeCode typeCode = [DataTypeEncoding getTypeWithAttribute:attributesChar];
NSString * typeStr = [DataTypeEncoding getSqlWithTypeCode:typeCode];
value = [NSString stringWithFormat:@"%@", value];
id defaultValue = [DataTypeEncoding defaultValueWithTypeCode:typeCode];
id defauleSize = [DataTypeEncoding defaultSizeWithTypeCode:typeCode];
NSDictionary * dic = @{
kSqlStoreNamed : propertyStr,
kSqlStoreValue : value,
kSqlStoreType : typeStr,
kSqlTableNamed : self.tableNameStr,
kSqlStoreDefaultValue : defautlValue,
kSqlStoreAutoIncrement : NO,
kSqlStorePrimaryKey : self.primaryKey,
kSqlStoreNotNull : NO,
kSqlStoreUnique : YES,
kSqlStoreSize : defauleSize
};
[_mappedDictionary setValue:value forKey:propertyStr];
[_mappedArray addObject:dic];
}
free(propertes);
}
On the basis of above-mentioned technical proposal, by obtained Basis of Database object placement model, data storage value, table name, Database upgrade reminder flag position, database special field processing flag bit are integrated, and obtain database object placement model.
The content not being described in detail in this specification belongs to prior art known to professional and technical personnel in the field.

Claims (6)

1. a kind of method caused by database object placement model, it is characterised in that comprise the following steps:
The input object that user sends is received,
The attribute of input object is read in real time,
According to preset protocol is read, input object and its attribute are changed, produce Basis of Database object placement model,
Database object placement model is further produced on the basis of Basis of Database object placement model,
Wherein:
Function when passing through system operation:Class_copyPropertyList () obtains generic attribute relevant information array,
Function when passing through operation:Property_getAttributes () obtains respective attributes information,
Corresponding information is obtained with reference to table by comparison system type,
Object type resolver is coordinated to parse the type of each data, the information being then mapped in database, including number According to information such as storehouse type, database default value, database default sizes,
Function property_getName () is parsed in object during with reference to operation, the Key values corresponding to this type attribute, so Afterwards data value corresponding to type is obtained using KeyValue.
2. method caused by database object placement model as claimed in claim 1, it is characterised in that:To input object and its Attribute carries out following processing successively, produces object type and type of database corresponding table:
Type conversion process is carried out to input object and its attribute,
Object type conversion process is carried out to input object and its attribute,
Type of database conversion process is carried out to input object and its attribute.
3. method caused by database object placement model as claimed in claim 2, it is characterised in that:By preset protocol, From input object and its attribute, following information is parsed:
Data default value,
Data default size,
Major key,
Data non-NULL limits.
4. method caused by database object placement model as claimed in claim 3, it is characterised in that:The object class that will be obtained Type and type of database corresponding table, data default value, data default size, major key, the limitation of data non-NULL are integrated, and obtain database Fundamental objects placement model.
5. method caused by database object placement model as claimed in claim 4, it is characterised in that:By preset protocol, From input object and its attribute, following information is parsed:
Data storage value,
Table name,
Database upgrade reminder flag position,
Database special field handles flag bit.
6. method caused by database object placement model as claimed in claim 5, it is characterised in that:The database that will be obtained Fundamental objects placement model, data storage value, table name, database upgrade reminder flag position, database special field processing mark Will position is integrated, and obtains database object placement model.
CN201710912806.1A 2017-09-30 2017-09-30 A kind of method caused by database object placement model Pending CN107577818A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710912806.1A CN107577818A (en) 2017-09-30 2017-09-30 A kind of method caused by database object placement model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710912806.1A CN107577818A (en) 2017-09-30 2017-09-30 A kind of method caused by database object placement model

Publications (1)

Publication Number Publication Date
CN107577818A true CN107577818A (en) 2018-01-12

Family

ID=61039007

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710912806.1A Pending CN107577818A (en) 2017-09-30 2017-09-30 A kind of method caused by database object placement model

Country Status (1)

Country Link
CN (1) CN107577818A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102346774A (en) * 2011-09-26 2012-02-08 深圳市信游天下网络科技有限公司 Database operation method and device
CN103425632A (en) * 2013-08-30 2013-12-04 深圳市路畅科技股份有限公司 Serializing method, device and processor
CN103853803A (en) * 2013-06-26 2014-06-11 携程计算机技术(上海)有限公司 Database configuration file encapsulation method and operation method as well as operation device thereof
CN105677323A (en) * 2015-12-31 2016-06-15 合肥大多数信息科技有限公司 Method for automatically generating database operation layer codes

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102346774A (en) * 2011-09-26 2012-02-08 深圳市信游天下网络科技有限公司 Database operation method and device
CN103853803A (en) * 2013-06-26 2014-06-11 携程计算机技术(上海)有限公司 Database configuration file encapsulation method and operation method as well as operation device thereof
CN103425632A (en) * 2013-08-30 2013-12-04 深圳市路畅科技股份有限公司 Serializing method, device and processor
CN105677323A (en) * 2015-12-31 2016-06-15 合肥大多数信息科技有限公司 Method for automatically generating database operation layer codes

Similar Documents

Publication Publication Date Title
CN103559217B (en) A kind of massive multicast data towards isomeric data storehouse warehouse-in implementation method
CN101807306A (en) Three-dimensional animation producing method and material independently exporting and importing method
CN106528674B (en) The High Performance Data Query method and apparatus being good for based on Hbase row
CN106528786B (en) Method and system of the multi-source heterogeneous power grid big data of fast transferring to HBase
CN105608088A (en) Method for automatically creating database and dynamically recording data on the basis of configuration file
CN102566990B (en) Method and device for performing data manipulation in Java application
US20020188366A1 (en) Plant information management system
CN102819609A (en) Modeling method for persisting data model
CN102004634A (en) Hierarchical business management system
CN108536745A (en) Tables of data extracting method, terminal, equipment and storage medium based on Shell
CN102447575B (en) A kind ofly resolve and manage the method for hexadecimal data journal file
CN102999600A (en) Method and system for automatically generating embedded database
CN102768666A (en) Method and system for storing and reading industrial data
CN103064661A (en) Computer monitoring configuration screen extensible makeup language (XML) descriptor system and method
CN108234299A (en) The information processing method of configurable protocol data gateway and gateway based on model
CN106598885B (en) A kind of working method of configurable multiport general data bridge system
CN103927168B (en) A kind of method and device of object-oriented data model persistence
CN107562955A (en) A kind of rapid generation of SQL statement
CN109739863A (en) Electric energy meter data managing method
CN107247721A (en) Visualize collecting method
CN106599241A (en) Big data visual management method for GIS software
CN107577818A (en) A kind of method caused by database object placement model
CN1851577A (en) Virtual control method for site controller
CN102521318A (en) General data exchange device based on extensible markup language (XML)
CN104281604B (en) Method and system for generating Target Link data dictionary hierarchical tree

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20180112

RJ01 Rejection of invention patent application after publication