CN104199907B - Insert the method and device of data - Google Patents

Insert the method and device of data Download PDF

Info

Publication number
CN104199907B
CN104199907B CN201410431113.7A CN201410431113A CN104199907B CN 104199907 B CN104199907 B CN 104199907B CN 201410431113 A CN201410431113 A CN 201410431113A CN 104199907 B CN104199907 B CN 104199907B
Authority
CN
China
Prior art keywords
data
entity class
tables
metadata
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410431113.7A
Other languages
Chinese (zh)
Other versions
CN104199907A (en
Inventor
黄伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Huaduo Network Technology Co Ltd
Original Assignee
Guangzhou Huaduo Network 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 Guangzhou Huaduo Network Technology Co Ltd filed Critical Guangzhou Huaduo Network Technology Co Ltd
Priority to CN201410431113.7A priority Critical patent/CN104199907B/en
Publication of CN104199907A publication Critical patent/CN104199907A/en
Application granted granted Critical
Publication of CN104199907B publication Critical patent/CN104199907B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/84Mapping; Conversion
    • G06F16/86Mapping to a database

Landscapes

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

Abstract

The invention discloses a kind of method and device for inserting data, belong to areas of information technology.Method includes:Obtain includes the entity class of check value according to what the corresponding data table metadata of at least one tables of data was set up;The check value that the corresponding entity class of tables of data according to determination includes to be inserted into data check success when, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into.The present invention includes the entity class of check value by obtaining according to what the corresponding data table metadata of at least one tables of data was set up, and the check value included according to the corresponding entity class of the tables of data for being inserted into data to be inserted into data check success when, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, it is achieved thereby that data are automatically inserted into;Further, since entity class includes check value so that data can be verified before by insertion of data into data table, the insertion efficiency of data is not only increased, the insertion effect of data is also optimized.

Description

Insert the method and device of data
Technical field
The present invention relates to areas of information technology, more particularly to a kind of method and device for inserting data.
Background technology
With continuing to develop for information technology, data volume rapid growth, this make it that the scale of database is increasing.Pass through The operations such as insertion data can be carried out to database by accessing database, so as to manage the data in database.Inserted by data During database, if the data of insertion do not meet the setting of database, insertion can be caused to fail.Therefore, how data to be inserted Enter database as problem of concern.
At present, access database when, by database API (Application Programming Interface, Application programming interface) connection database;Manual creation database inserts sentence;Inserted by database API according to database Enter sentence by insertion of data into data storehouse.
During the present invention is realized, inventor has found that above-mentioned technology at least has problems with:
Because mistake easily occurs in the database parenthesis Jurong of manual creation, and establishment process is relatively time consuming, causes in data The less efficient of data is inserted in storehouse.In addition, directly inserting sentence by insertion of data into data according to database by database API Storehouse, easily causes data insertion failure so that the insertion effect of database data is poor.
The content of the invention
In order to solve problem of the prior art, the embodiments of the invention provide a kind of method and device for inserting data.Institute State technical scheme as follows:
First aspect includes there is provided a kind of method for inserting data, methods described:
The entity class set up according to the corresponding data table metadata of at least one tables of data is obtained, the entity class includes Check value, one entity class of each tables of data correspondence;
Determine to be inserted into the tables of data of data, and the school included according to the corresponding entity class of the tables of data in database Value is tested to verify the data being inserted into the tables of data;
If verifying successfully, the data being inserted into are inserted by the data according to the corresponding entity class of the tables of data Table.
With reference in a first aspect, in the first possible implementation of first aspect, the acquisition is according at least one The entity class that the corresponding data table metadata of tables of data is set up, including:
Obtain the corresponding data table metadata of at least one tables of data;
Create the corresponding entity class metadata of each data table metadata;
The corresponding check value of each entity class is set, and according to the corresponding check value of each entity class and each entity class member The corresponding entity class of each tables of data of data creation, each entity class includes the check value set and creates the entity class Entity class metadata.
With reference to the first possible implementation of first aspect, in second of possible implementation of first aspect In, the data table metadata includes data sheet field type;It is described to create the corresponding entity class of each data table metadata Before metadata, in addition to:
Mapping table is set up, the mapping table includes the data type pass corresponding with the data type of entity class of database System;
It is described to create the corresponding entity class metadata of each data table metadata, including:
The corresponding entity class field type of each data sheet field type is created according to the mapping table, and by the entity Class field type as establishment entity class metadata.
With reference to the first possible implementation of first aspect, in the third possible implementation of first aspect In, the data table metadata includes the default value of data sheet field;It is described to create the corresponding reality of each data table metadata Body class metadata, including:
The default value that each entity class field is created in constructed fuction is the default value of corresponding each data sheet field, And using the default value of the entity class field as establishment entity class metadata.
With reference to second of first aspect or the third possible implementation, in the 4th kind of possible reality of first aspect In existing mode, the corresponding check value of each entity class of basis and each tables of data of each entity class metadata establishment are corresponding After entity class, in addition to:
The entity class metadata generation database insertion sentence included according to the entity class, by the database parenthesis Sentence as the entity class basic function;
It is described that the data being inserted into are inserted by the tables of data according to the corresponding entity class of the tables of data, including:
The data being inserted into are inserted by the tables of data according to the basic function of the corresponding entity class of the tables of data.
With reference to second of first aspect or the third possible implementation, in the 5th kind of possible reality of first aspect It is described that the data being inserted into are inserted by the tables of data according to the corresponding entity class of the tables of data in existing mode, including:
The entity class metadata that entity class corresponding to the tables of data includes carries out assembled;
Database insertion sentence is generated according to the assembled result of the entity class metadata;
The data being inserted into are inserted by the tables of data according to the insertion sentence.
Second aspect includes there is provided a kind of device for inserting data, described device:
Acquisition module, for obtaining the entity class set up according to the corresponding data table metadata of at least one tables of data, institute Stating entity class includes check value, one entity class of each tables of data correspondence;
Determining module, the tables of data for determining to be inserted into data in database;
Correction verification module, for the check value that is included according to the corresponding entity class of the tables of data to being treated in the tables of data The data of insertion are verified;
Module is inserted, for when verifying successfully, according to the corresponding entity class of the tables of data by the number being inserted into According to the insertion tables of data.
With reference to second aspect, in the first possible implementation of second aspect, the acquisition module, including:
Acquiring unit, for obtaining the corresponding data table metadata of at least one tables of data;
First creating unit, for creating the corresponding entity class metadata of each data table metadata;
Setting unit, for setting the corresponding check value of each entity class;
Second creating unit, for creating each according to the corresponding check value of each entity class and each entity class metadata The corresponding entity class of tables of data, each entity class includes the check value set and the entity class member number for creating the entity class According to.
With reference to the first possible implementation of second aspect, in second of possible implementation of second aspect In, the data table metadata that the acquiring unit is got includes data sheet field type;
The acquisition module, in addition to:
Unit is set up, for setting up mapping table, the mapping table includes the data type of database and the data of entity class The corresponding relation of type;
First creating unit, for creating the corresponding entity class of each data sheet field type according to the mapping table Field type, and using the entity class field type as establishment entity class metadata.
With reference to the first possible implementation of second aspect, in the third possible implementation of second aspect In, the data table metadata that the acquiring unit is got includes the default value of data sheet field;
First creating unit, the default value for creating each entity class field in constructed fuction is corresponding every The default value of individual data sheet field, and using the default value of the entity class field as establishment entity class metadata.
With reference to second of second aspect or the third possible implementation, in the 4th kind of possible reality of second aspect In existing mode, the acquisition module, in addition to:
Generation unit, for the entity class metadata generation database insertion sentence included according to the entity class, by institute Database insertion sentence is stated as the basic function of the entity class;
The insertion module, for the basic function according to the corresponding entity class of the tables of data by the number being inserted into According to the insertion tables of data.
With reference to second of second aspect or the third possible implementation, in the 5th kind of possible reality of second aspect In existing mode, the insertion module, for being spelled to the entity class metadata that the corresponding entity class of the tables of data includes Dress;Database insertion sentence is generated according to the assembled result of the entity class metadata;Treated according to the insertion sentence by described The data of insertion insert the tables of data.
The beneficial effect that technical scheme provided in an embodiment of the present invention is brought is:
Include the entity class of check value according to what the corresponding data table metadata of at least one tables of data was set up by obtaining, And the check value included according to the corresponding entity class of the tables of data for being inserted into data is to the data check that is inserted into tables of data During success, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, it is achieved thereby that the automatic of data inserts Enter;Further, since entity class includes check value so that data can be verified before by insertion of data into data table, no The insertion efficiency of data is improve only, the insertion effect of data is also optimized.
Brief description of the drawings
Technical scheme in order to illustrate the embodiments of the present invention more clearly, makes required in being described below to embodiment Accompanying drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the present invention, for For those of ordinary skill in the art, on the premise of not paying creative work, other can also be obtained according to these accompanying drawings Accompanying drawing.
Fig. 1 is the flow chart of the method for the insertion data that one embodiment of the invention is provided;
Fig. 2 is the flow chart of the method for the insertion data that another embodiment of the present invention is provided;
Fig. 3 is the structural representation of the device for the insertion data that another embodiment of the present invention is provided;
Fig. 4 is the structural representation for the acquisition module that another embodiment of the present invention is provided;
Fig. 5 is the structural representation for the acquisition module that another embodiment of the present invention is provided;
Fig. 6 is the structural representation for the acquisition module that another embodiment of the present invention is provided;
Fig. 7 is the structural representation of the device for the insertion data that another embodiment of the present invention is provided.
Embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to embodiment party of the present invention Formula is described in further detail.
For at present when by insertion of data into data storehouse, it is necessary to which manual creation database inserts sentence so as to database Insert data it is less efficient the problem of, the embodiments of the invention provide it is a kind of insert data method, referring to Fig. 1, method stream Journey includes:
101:The entity class set up according to the corresponding data table metadata of at least one tables of data is obtained, entity class includes Check value, one entity class of each tables of data correspondence;
As a kind of alternative embodiment, the entity set up according to the corresponding data table metadata of at least one tables of data is obtained Class, including:
Obtain the corresponding data table metadata of at least one tables of data;
Create the corresponding entity class metadata of each data table metadata;
The corresponding check value of each entity class is set, and according to the corresponding check value of each entity class and each entity class member The corresponding entity class of each tables of data of data creation, each entity class includes the check value set and the entity for creating entity class Class metadata.
As a kind of alternative embodiment, data table metadata includes data sheet field type;Create each data list cell Before the corresponding entity class metadata of data, in addition to:
Mapping table is set up, mapping table includes the corresponding relation of the data type of database and the data type of entity class;
The corresponding entity class metadata of each data table metadata is created, including:
The corresponding entity class field type of each data sheet field type is created according to mapping table, and by entity class field class Type as establishment entity class metadata.
As a kind of alternative embodiment, data table metadata includes the default value of data sheet field;Create each data The corresponding entity class metadata of table metadata, including:
The default value that each entity class field is created in constructed fuction is the default value of corresponding each data sheet field, And using the default value of entity class field as establishment entity class metadata.
As a kind of alternative embodiment, create every according to the corresponding check value of each entity class and each entity class metadata After the corresponding entity class of individual tables of data, in addition to:
The entity class metadata generation database insertion sentence included according to entity class, regard database insertion sentence as reality The basic function of body class.
102:Determine to be inserted into the tables of data of data, and the school included according to the corresponding entity class of tables of data in database Value is tested to verify the data being inserted into tables of data;
103:If verifying successfully, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into.
As a kind of alternative embodiment, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, wrap Include:
According to the basic function of the corresponding entity class of tables of data by the insertion of data into data table being inserted into.
As a kind of alternative embodiment, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, wrap Include:
The entity class metadata that entity class corresponding to tables of data includes carries out assembled;
Database insertion sentence is generated according to the assembled result of entity class metadata;
According to insertion sentence by the insertion of data into data table being inserted into.
Method provided in an embodiment of the present invention, is built by obtaining according to the corresponding data table metadata of at least one tables of data Vertical includes the entity class of check value, and the check value logarithm included according to the corresponding entity class of the tables of data for being inserted into data During according to the data check success being inserted into table, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, It is achieved thereby that data are automatically inserted into;Further, since entity class includes check value so that before by insertion of data into data table Data can be verified, not only increase the insertion efficiency of data, also optimize the insertion effect of data.
The embodiments of the invention provide it is a kind of insert data method, the content of the embodiment with reference to shown in above-mentioned Fig. 1, with This method is applied to exemplified by C Plus Plus environment, method provided in an embodiment of the present invention is carried out explanation is explained in detail.Referring to figure 2, method flow includes:
201:Obtain the corresponding data table metadata of at least one tables of data;
Due to multiple tables of data may be included in a database, for the insertion of data into data storehouse that will be inserted into, this reality The method for applying example offer obtains the corresponding data table metadata of at least one tables of data.On obtaining at least one tables of data correspondence Data table metadata mode, the present embodiment is not especially limited.Looked into when it is implemented, can be performed by the API of database Table structure command is ask, so as to obtain the corresponding data table metadata of at least one tables of data;Wherein, data table metadata include but Be not limited to data sheet field name, data sheet field type, data sheet field length, the default value of data sheet field, whether based on Key and whether be from adding.
202:Create the corresponding entity class metadata of each data table metadata;
Wherein, entity class be Object-Oriented Systems in class, entity class metadata be Object-Oriented Systems in class member Data.
Mode on creating the corresponding entity class metadata of each data table metadata, the present embodiment does not make specific limit It is fixed.When it is implemented, different establishment modes can be used according to different entity class metadata.For being wrapped in data table metadata Including data sheet field type and data table metadata includes the situation of data sheet field type, present embodiments provide including But it is not limited to the mode that the following two kinds creates entity class metadata:
First way:Data table metadata includes data sheet field type, creates each data table metadata correspondence Entity class metadata before, in addition to:
Mapping table is set up, mapping table includes the corresponding relation of the data type of database and the data type of entity class;
The corresponding entity class metadata of each data table metadata is created, including:
The corresponding entity class field type of each data sheet field type is created according to mapping table, and by entity class field class Type as establishment entity class metadata.
Due to mapping table including database data type and entity class data type corresponding relation, then can be according to reflecting The corresponding relation of the data type for the database that firing table includes and the data type of entity class creates each data sheet field class The corresponding entity class field type of type.
To insert data instance into database by C++, then entity class metadata corresponds to C++ metadata, entity class word Segment type correspondence C++ field types, mapping table includes the data type of database and C++ data type corresponding relation, root The C++ field types corresponding to data sheet field type are created according to the corresponding relation.
The second way:Data table metadata includes the default value of data sheet field, creates each data table metadata Corresponding entity class metadata, including:
The default value that each entity class field is created in constructed fuction is the default value of corresponding each data sheet field, And using the default value of entity class field as establishment entity class metadata.
Wherein, constructed fuction is used to, in the object in creating entity class, initialize object, and as object assigns initial value; Entity class field is used for the attribute for identifying object in entity class;The default value of data sheet field is set when being the data table definitions field The default value put.
It is the silent of corresponding each data sheet field on creating the default value of each entity class field in constructed fuction Recognize the mode of value, the present embodiment is not especially limited.When it is implemented, can be in the corresponding number of at least one tables of data got According to the default value of searching data literary name section in table metadata, the default value of the corresponding data sheet field found is regard as establishment Each entity class field default value.
203:The corresponding check value of each entity class is set, and according to the corresponding check value of each entity class and each entity Class metadata creates the corresponding entity class of each tables of data, and each entity class includes the check value set and creates entity class Entity class metadata;
Wherein, check value includes but is not limited to length check value and type checking value, and the present embodiment is not in check value Hold and size is defined.Mode on setting check value, the present embodiment is equally not especially limited.Using check value as length Exemplified by check value, due to potentially including multiple fields in an entity class, when it is implemented, can be passed through according to data table metadata Set Value interfaces are that each field in entity class sets corresponding length check value.Further, since each tables of data is set Possible difference is put, and the different entity class of different tables of data correspondences, therefore, the method that the present embodiment is provided can be for each real Body class sets corresponding check value.
Further, each tables of data is being created according to the corresponding check value of each entity class and each entity class metadata During corresponding entity class, because tables of data is corresponding with data table metadata, data table metadata correspondent entity class metadata is then counted It is corresponding with entity class metadata according to table, therefore, it can be created according to the corresponding check value of each entity class and each entity class metadata The corresponding entity class of each tables of data is built, each entity class includes the check value set and the entity class member number for creating entity class According to so that tables of data one entity class of correspondence.
It is corresponding on creating each tables of data according to the corresponding check value of each entity class and each entity class metadata The mode of entity class, the present embodiment is not especially limited.When it is implemented, can be corresponding at least one tables of data got The corresponding data table metadata of each tables of data is searched in data table metadata, further according to each data table metadata pair of establishment The entity class metadata answered obtains the corresponding entity class metadata of each tables of data, by the check value of setting and each data list cell The corresponding entity class metadata write-in tables of data entity class file of data, obtains the corresponding entity class of each tables of data.
As a kind of alternative embodiment, create every according to the corresponding check value of each entity class and each entity class metadata After the corresponding entity class of individual tables of data, also include but is not limited to:
The entity class metadata generation database insertion sentence included according to entity class, regard database insertion sentence as reality The basic function of body class.
As shown in the above, the method that the present embodiment is provided also includes generation database parenthesis when creating entity class The step of sentence.The mode of sentence is inserted on generation database, the present embodiment is not especially limited.When it is implemented, available The entity class metadata that code generator is included by entity class generates database and inserts sentence, and then database is inserted into sentence It is used as the basic function of entity class.Wherein, entity class metadata includes but is not limited to entity class field type, entity class field name And the constraint of entity class field etc., the constraint of entity class field includes but is not limited to entity class data length, entity class data value model Enclose, the basic function of entity class includes but is not limited to GetInsert ().
It should be noted that in addition to the entity class metadata generation database insertion sentence included according to entity class, also The sentences such as entity class metadata generation data base querying, renewal and the deletion that can be included according to entity class;Correspondingly, entity class Basic function also includes GetSelect (), GetUpdate () and GetDelete () etc..
As a kind of alternative embodiment, the method that the present embodiment is provided also includes but is not limited to each entity according to setting The corresponding check value of class generates corresponding verification expression formula;Wherein, the verification expression formula of generation can be integrated in Set Value and connect In mouthful, when an entity class includes multiple fields, correspondence is generated also directed to the check value that each field is set in entity class Verification value expression.
Further, if the corresponding verification expression formula of each entity class is generated, according to the corresponding school of each entity class Test value and when each entity class metadata creates each tables of data corresponding entity class, can be according to the corresponding verification of each entity class Expression formula and each entity class metadata create the corresponding entity class of each tables of data, and each entity class includes the verification of generation Expression formula and the entity class metadata for creating entity class.
Further, completed by above-mentioned steps 201 to step 203 and obtain corresponding according at least one tables of data The entity class that data table metadata is set up, in order to complete the side for providing the tables of data in insertion of data into data storehouse, the present embodiment Method also includes subsequent step.
204:Determine to be inserted into the tables of data of data, and the school included according to the corresponding entity class of tables of data in database Value is tested to verify the data being inserted into tables of data;
Because database includes at least one tables of data, the corresponding check value of different tables of data is different, accordingly, it would be desirable to really Determine to be inserted into the tables of data of data in database.On the mode for the tables of data for determining to be inserted into data in database, this implementation Example is not especially limited.When it is implemented, the tables of data mark of input can be obtained, determined according to tables of data mark in database It is inserted into the tables of data of data.Certainly, in addition to aforesaid way, it can also be determined according to the attribute for the data being inserted into database It is inserted into the tables of data of data.
Further, on the check value that is included according to the corresponding entity class of tables of data to the number that is inserted into tables of data According to the mode verified, the present embodiment is not especially limited.So that check value is length check value as an example, when it is implemented, can By the incoming length value of Get Value interfaces, length check is carried out in Set Value interfaces;When incoming length value exceeds During the length check value of setting, throw exception.
As a kind of alternative embodiment, if according to the corresponding verification expression formula of each entity class and each entity class member number According to the corresponding entity class of each tables of data of establishment, then the verification expression formula pair that can be also included according to the corresponding entity class of tables of data The data being inserted into are verified.On the mode verified according to verification expression formula to the data being inserted into, the present embodiment It is not especially limited.By taking verification expression formula as follows as an example, the verification expression formula shows that field age span is 0 To 150;If verification expression formula is integrated in SetValue interfaces, the data being inserted into are judged in Set Value interfaces Whether in the range of 0 to 150;If not in the range of 0 to 150, throw exception.
If(!(0<=ageValue&&ageValue<=150))
{
Throw Exception;
}
School is carried out to the data being inserted into tables of data by the check value included according to the corresponding entity class of tables of data Test, the data check of data Layer is advanceed into application layer completes, and improves the efficiency of insertion data.
205:If verifying successfully, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into.
When verifying successfully, show the setting for the tables of data that the data fit being inserted into is determined, therefore, can be according to tables of data Corresponding entity class is by the insertion of data into data table being inserted into.Including but not limited to the following two kinds is present embodiments provided according to number According to the corresponding entity class of table by the mode for the insertion of data into data table being inserted into:
First way:According to the basic function of the corresponding entity class of tables of data by the insertion of data into data table being inserted into;
Wherein, because the database of the entity class metadata generation included according to entity class inserts sentence as entity class Basic function, therefore, can be according to the basic function of the corresponding entity class of the tables of data by the insertion of data into data table being inserted into.
The second way:The entity class metadata that entity class corresponding to tables of data includes carries out assembled;According to entity The assembled result generation database insertion sentence of class metadata;According to insertion sentence by the insertion of data into data table being inserted into.
Wherein, the entity class metadata on including to the corresponding entity class of tables of data carries out assembled mode, this reality Example is applied to be not especially limited.When it is implemented, SQL (Structured Query Language, structuralized query language can be passed through Speech) the entity class metadata that includes to entity class of assembled device carries out assembled, generated according to the assembled result of entity class metadata SQL statement is inserted, the insertion SQL statement is database insertion sentence.In addition, the entity class member that can also include to entity class Data progress is assembled, according to SQL statements such as the assembled result of entity class metadata generation inquiry, renewal and deletions.
If it should be noted that generating database insertion sentence when creating entity class, using first way will The insertion of data into data table being inserted into;If database insertion sentence is not generated when creating entity class, using the second way By the insertion of data into data table being inserted into.On the specific implementation of both inserted modes, the present embodiment does not make specific limit It is fixed.When it is implemented, the api interface that can be provided by database manufacturer, basic function or the database insertion of incoming entity class Sentence, sentence is inserted by the insertion of data into data table being inserted into according to the basic function of entity class or database;Wherein, entity class Basic function can be SQL function, database insertion sentence can be SQL statement.
Further, after according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, acquisition insert Enter result for return value, return value includes success or failure.
Method provided in an embodiment of the present invention, is built by obtaining according to the corresponding data table metadata of at least one tables of data Vertical includes the entity class of check value, and the check value logarithm included according to the corresponding entity class of the tables of data for being inserted into data During according to the data check success being inserted into table, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, It is achieved thereby that data are automatically inserted into;Further, since entity class includes check value so that before by insertion of data into data table Data can be verified, not only increase the insertion efficiency of data, also optimize the insertion effect of data.
Referring to Fig. 3, the embodiments of the invention provide a kind of device for inserting data, the device be used to performing above-mentioned Fig. 1 or The method that embodiment shown in Fig. 2 is provided.The device includes:
Acquisition module 301, for obtaining the entity class set up according to the corresponding data table metadata of at least one tables of data, Entity class includes check value, one entity class of each tables of data correspondence;
Determining module 302, the tables of data for determining to be inserted into data in database;
Correction verification module 303, for the check value that is included according to the corresponding entity class of tables of data to being inserted into tables of data Data verified;
Module 304 is inserted, for when verifying successfully, the data being inserted into being inserted according to the corresponding entity class of tables of data Tables of data.
As a kind of alternative embodiment, referring to Fig. 4, acquisition module 301, including:
Acquiring unit 3011, for obtaining the corresponding data table metadata of at least one tables of data;
First creating unit 3012, for creating the corresponding entity class metadata of each data table metadata;
Setting unit 3013, for setting the corresponding check value of each entity class;
Second creating unit 3014, for according to the corresponding check value of each entity class and the establishment of each entity class metadata The corresponding entity class of each tables of data, each entity class includes the check value set and the entity class member number for creating entity class According to.
As a kind of alternative embodiment, the data table metadata that acquiring unit 3011 is got includes data sheet field class Type;
Referring to Fig. 5, acquisition module 301, in addition to:
Unit 3015 is set up, for setting up mapping table, mapping table includes the data type of database and the data of entity class The corresponding relation of type;
First creating unit 3012, for creating the corresponding entity class field of each data sheet field type according to mapping table Type, and using entity class field type as establishment entity class metadata.
As a kind of alternative embodiment, the data table metadata that acquiring unit 3011 is got includes data sheet field Default value;
First creating unit 3012, the default value for creating each entity class field in constructed fuction is corresponding every The default value of individual data sheet field, and using the default value of entity class field as establishment entity class metadata.
As a kind of alternative embodiment, referring to Fig. 6, acquisition module 301, in addition to:
Generation unit 3016, for the entity class metadata generation database insertion sentence included according to entity class, by number Sentence is inserted as the basic function of entity class according to storehouse;
Module 304 is inserted, the data being inserted into are inserted into number for the basic function according to the corresponding entity class of tables of data According to table.
As a kind of alternative embodiment, module 304 is inserted, for the entity class included to the corresponding entity class of tables of data Metadata carries out assembled;Database insertion sentence is generated according to the assembled result of entity class metadata;It will be treated according to insertion sentence The insertion of data into data table of insertion.
Device provided in an embodiment of the present invention, is built by obtaining according to the corresponding data table metadata of at least one tables of data Vertical includes the entity class of check value, and the check value logarithm included according to the corresponding entity class of the tables of data for being inserted into data During according to the data check success being inserted into table, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, It is achieved thereby that data are automatically inserted into;Further, since entity class includes check value so that before by insertion of data into data table Data can be verified, not only increase the insertion efficiency of data, also optimize the insertion effect of data.
Fig. 7 is a kind of block diagram of the device 1000 of insertion data according to an exemplary embodiment.For example, device 1000 can be computer, messaging devices, tablet device, personal digital assistant, server etc..
Reference picture 7, device 1000 can include following one or more assemblies:Processing assembly 1002, memory 1004, electricity Source component 1006, multimedia groupware 1008, audio-frequency assembly 1010, I/O (Input/Output, input/output) interface 1012, Sensor cluster 1014, and communication component 1016.
The integrated operation of the usual control device 1000 of processing assembly 1002, such as with display, call, data communication, The camera operation operation associated with record operation.Processing assembly 1002 can include one or more processors 1020 to perform Instruction, to complete all or part of step of above-mentioned method.In addition, processing assembly 1002 can include one or more moulds Block, is easy to the interaction between processing assembly 1002 and other assemblies.For example, processing assembly 1002 can include multi-media module, To facilitate the interaction between multimedia groupware 1008 and processing assembly 1002.
Memory 1004 is configured as storing various types of data supporting the operation in device 1000.These data Example includes the instruction of any application program or method for being used to operate on device 1000, contact data, telephone book data, Message, picture, video etc..Memory 1004 can by any kind of volatibility or non-volatile memory device or they Combination realization, such as SRAM (Static Random Access Memory, static RAM), EEPROM (Electrically-Erasable Programmable Read-Only Memory, the read-only storage of electrically erasable Device), EPROM (Erasable Programmable Read Only Memory, Erasable Programmable Read Only Memory EPROM), PROM (Programmable Read-Only Memory, programmable read only memory), and ROM (Read-Only Memory, it is read-only to deposit Reservoir), magnetic memory, flash memory, disk or CD.
Power supply module 1006 provides electric power for the various assemblies of device 1000.Power supply module 1006 can include power management System, one or more power supplys, and other components associated with generating, managing and distributing electric power for device 1000.
Multimedia groupware 1008 is included in the screen of one output interface of offer between described device 1000 and user. In some embodiments, screen can include LCD (Liquid Crystal Display, liquid crystal display) and TP (Touch Panel, touch panel).If screen includes touch panel, screen may be implemented as touch-screen, to receive from user's Input signal.Touch panel includes one or more touch sensors with the gesture on sensing touch, slip and touch panel.Institute State touch sensor can not only sensing touch or sliding action border, but also detection touches or slide phase with described The duration of pass and pressure.In certain embodiments, multimedia groupware 1008 includes a front camera and/or rearmounted taken the photograph As head.When device 1000 is in operator scheme, such as screening-mode or during video mode, front camera and/or rear camera The multi-medium data of outside can be received.Each front camera and rear camera can be a fixed optical lens systems Unite or with focusing and optical zoom capabilities.
Audio-frequency assembly 1010 is configured as output and/or input audio signal.For example, audio-frequency assembly 1010 includes one MIC (Microphone, microphone), when device 1000 is in operator scheme, such as call model, logging mode and speech recognition mould During formula, microphone is configured as receiving external audio signal.The audio signal received can be further stored in memory 1004 or sent via communication component 1016.In certain embodiments, audio-frequency assembly 1010 also includes a loudspeaker, for defeated Go out audio signal.
I/O interfaces 1012 are that interface, above-mentioned peripheral interface module are provided between processing assembly 1002 and peripheral interface module Can be keyboard, click wheel, button etc..These buttons may include but be not limited to:Home button, volume button, start button and Locking press button.
Sensor cluster 1014 includes one or more sensors, and the state for providing various aspects for device 1000 is commented Estimate.For example, sensor cluster 1014 can detect opening/closed mode of device 1000, the relative positioning of component, such as group Part is the display and keypad of device 1000, and sensor cluster 1014 can be with 1,000 1 groups of detection means 1000 or device The position of part changes, the existence or non-existence that user contacts with device 1000, the orientation of device 1000 or acceleration/deceleration and device 1000 temperature change.Sensor cluster 1014 can include proximity transducer, be configured to connect in not any physics The presence of object nearby is detected when touching.Sensor cluster 1014 can also include optical sensor, such as CMOS (Complementary Metal Oxide Semiconductor, CMOS) or CCD (Charge-coupled Device, Charged Couple Element) imaging sensor, for being used in imaging applications.In certain embodiments, the sensor cluster 1014 can also be wrapped Include acceleration transducer, gyro sensor, Magnetic Sensor, pressure sensor or temperature sensor.
Communication component 1016 is configured to facilitate the communication of wired or wireless way between device 1000 and other equipment.Dress The wireless network based on communication standard, such as WiFi, 2G or 3G, or combinations thereof can be accessed by putting 1000.It is exemplary at one In embodiment, communication component 1016 receives broadcast singal or broadcast correlation from external broadcasting management system via broadcast channel Information.In one exemplary embodiment, the communication component 1016 also include NFC (Near Field Communication, Near-field communication) module, to promote junction service.For example, RFID (Radio Frequency can be based in NFC module Identification, radio frequency identification) technology, IrDA (Infra-red Data Association, Infrared Data Association) skill Art, UWB (Ultra Wideband, ultra wide band) technology, BT (Bluetooth, bluetooth) technologies and other technologies are realized.
In the exemplary embodiment, device 1000 can be by one or more ASIC (Application Specific Integrated Circuit, application specific integrated circuit), DSP is (at Digital signal Processor, data signal Manage device), DSPD (Digital signal Processor Device, digital signal processing appts), PLD (Programmable Logic Device, PLD), FPGA) (Field Programmable Gate Array, field programmable gate Array), controller, microcontroller, microprocessor or other electronic components realize, for performing the above method.
In the exemplary embodiment, a kind of non-transitorycomputer readable storage medium including instructing, example are additionally provided Such as include the memory 1004 of instruction, above-mentioned instruction can be performed to complete the above method by the processor 1020 of device 1000.Example Such as, the non-transitorycomputer readable storage medium can be ROM, RAM (Random Access Memory, arbitrary access Memory), CD-ROM (Compact Disc Read-Only Memory, compact disc read-only memory), tape, floppy disk and light number According to storage device etc..
Device 1000 includes memory, and one or more than one program, one of them or more than one Program storage is configured to by one or more than one computing device in memory.It is one or one with Upper program bag contains the instruction for the operation for being used to perform the insertion data described in above-described embodiment.
Device provided in an embodiment of the present invention, is built by obtaining according to the corresponding data table metadata of at least one tables of data Vertical includes the entity class of check value, and the check value logarithm included according to the corresponding entity class of the tables of data for being inserted into data During according to the data check success being inserted into table, according to the corresponding entity class of tables of data by the insertion of data into data table being inserted into, It is achieved thereby that data are automatically inserted into;Further, since entity class includes check value so that before by insertion of data into data table Data can be verified, not only increase the insertion efficiency of data, also optimize the insertion effect of data.
It should be noted that:The device for the insertion data that above-described embodiment is provided is when inserting data, only with above-mentioned each work( The division progress of energy module is for example, in practical application, as needed can distribute above-mentioned functions by different functions Module is completed, i.e., the internal structure of device is divided into different functional modules, described above all or part of to complete Function.In addition, the device for the insertion data that above-described embodiment is provided and the embodiment of the method for insertion data belong to same design, its The process of implementing refers to embodiment of the method, repeats no more here.
The embodiments of the present invention are for illustration only, and the quality of embodiment is not represented.
One of ordinary skill in the art will appreciate that realizing that all or part of step of above-described embodiment can be by hardware To complete, the hardware of correlation can also be instructed to complete by program, described program can be stored in a kind of computer-readable In storage medium, storage medium mentioned above can be read-only storage, disk or CD etc..
The foregoing is only presently preferred embodiments of the present invention, be not intended to limit the invention, it is all the present invention spirit and Within principle, any modification, equivalent substitution and improvements made etc. should be included in the scope of the protection.

Claims (10)

1. a kind of method for inserting data, it is characterised in that methods described includes:
Obtain the corresponding data table metadata of at least one tables of data;
Create the corresponding entity class metadata of each data table metadata;
The corresponding check value of each entity class is set, it is corresponding according to the check value generation that each field is set in each entity class Verify expression formula;
The corresponding entity of each tables of data is created according to the corresponding verification expression formula of each entity class and each entity class metadata Class, each entity class includes the verification expression formula of generation and creates the entity class metadata of entity class, each tables of data correspondence One entity class;
Determine to be inserted into the tables of data of data, and the checklist included according to the corresponding entity class of the tables of data in database The data being inserted into the tables of data are verified up to formula;
If verifying successfully, the data being inserted into are inserted by the tables of data according to the corresponding entity class of the tables of data.
2. according to the method described in claim 1, it is characterised in that the data table metadata includes data sheet field class Type;It is described create the corresponding entity class metadata of each data table metadata before, in addition to:
Mapping table is set up, the mapping table includes the corresponding relation of the data type of database and the data type of entity class;
It is described to create the corresponding entity class metadata of each data table metadata, including:
The corresponding entity class field type of each data sheet field type is created according to the mapping table, and by the entity class word Segment type as establishment entity class metadata.
3. according to the method described in claim 1, it is characterised in that the data table metadata includes the silent of data sheet field Recognize value;It is described to create the corresponding entity class metadata of each data table metadata, including:
The default value that each entity class field is created in constructed fuction is the default value of corresponding each data sheet field, and will The default value of the entity class field as establishment entity class metadata.
4. according to the method in claim 2 or 3, it is characterised in that the corresponding check value of each entity class of basis and Each entity class metadata is created after the corresponding entity class of each tables of data, in addition to:
The entity class metadata generation database insertion sentence included according to the entity class, database insertion sentence is made For the basic function of the entity class;
It is described that the data being inserted into are inserted by the tables of data according to the corresponding entity class of the tables of data, including:
The data being inserted into are inserted by the tables of data according to the basic function of the corresponding entity class of the tables of data.
5. according to the method in claim 2 or 3, it is characterised in that described to be incited somebody to action according to the corresponding entity class of the tables of data The data being inserted into insert the tables of data, including:
The entity class metadata that entity class corresponding to the tables of data includes carries out assembled;
Database insertion sentence is generated according to the assembled result of the entity class metadata;
The data being inserted into are inserted by the tables of data according to the insertion sentence.
6. a kind of device for inserting data, it is characterised in that described device includes:
Acquisition module, for obtaining the entity class set up according to the corresponding data table metadata of at least one tables of data, the reality Body class includes check value, one entity class of each tables of data correspondence;
Determining module, the tables of data for determining to be inserted into data in database;
Correction verification module, for the verification expression formula that is included according to the corresponding entity class of the tables of data to being treated in the tables of data The data of insertion are verified;
Module is inserted, for when verifying successfully, the data being inserted into being inserted according to the corresponding entity class of the tables of data Enter the tables of data;
The acquisition module, including:
Acquiring unit, for obtaining the corresponding data table metadata of at least one tables of data;
First creating unit, for creating the corresponding entity class metadata of each data table metadata;
Setting unit, for setting the corresponding check value of each entity class;
Second creating unit, for creating each according to the corresponding verification expression formula of each entity class and each entity class metadata The corresponding entity class of tables of data, each entity class includes the verification expression formula set and the entity class member for creating the entity class Data;
Described device is additionally operable to:
Corresponding verification expression formula is generated according to the check value that each field is set in each entity class.
7. device according to claim 6, it is characterised in that wrapped in the data table metadata that the acquiring unit is got Include data sheet field type;
The acquisition module, in addition to:
Unit is set up, for setting up mapping table, the mapping table includes the data type of database and the data type of entity class Corresponding relation;
First creating unit, for creating the corresponding entity class field of each data sheet field type according to the mapping table Type, and using the entity class field type as establishment entity class metadata.
8. device according to claim 6, it is characterised in that wrapped in the data table metadata that the acquiring unit is got Include the default value of data sheet field;
First creating unit, for creating the default value of each entity class field in constructed fuction to be corresponding per number According to the default value of literary name section, and using the default value of the entity class field as establishment entity class metadata.
9. the device according to claim 7 or 8, it is characterised in that the acquisition module, in addition to:
Generation unit, for the entity class metadata generation database insertion sentence included according to the entity class, by the number Sentence is inserted as the basic function of the entity class according to storehouse;
The insertion module, inserts the data being inserted into for the basic function according to the corresponding entity class of the tables of data Enter the tables of data.
10. the device according to claim 7 or 8, it is characterised in that the insertion module, for the tables of data pair The entity class metadata that the entity class answered includes carries out assembled;Data are generated according to the assembled result of the entity class metadata Sentence is inserted in storehouse;The data being inserted into are inserted by the tables of data according to the insertion sentence.
CN201410431113.7A 2014-08-28 2014-08-28 Insert the method and device of data Active CN104199907B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410431113.7A CN104199907B (en) 2014-08-28 2014-08-28 Insert the method and device of data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410431113.7A CN104199907B (en) 2014-08-28 2014-08-28 Insert the method and device of data

Publications (2)

Publication Number Publication Date
CN104199907A CN104199907A (en) 2014-12-10
CN104199907B true CN104199907B (en) 2017-08-25

Family

ID=52085200

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410431113.7A Active CN104199907B (en) 2014-08-28 2014-08-28 Insert the method and device of data

Country Status (1)

Country Link
CN (1) CN104199907B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959377B (en) * 2018-05-25 2020-11-06 联动优势电子商务有限公司 Data processing method, device and storage medium
CN109753639B (en) * 2018-12-29 2023-05-30 东软集团股份有限公司 Front-background unified verification method and device, storage medium and electronic equipment
CN113111116B (en) * 2021-05-12 2022-10-18 国家海洋信息中心 Ocean water environment data integration method of ocean comprehensive database

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008952A (en) * 2007-01-30 2007-08-01 华为技术有限公司 Method and device for generating persistence layer
CN102314414A (en) * 2010-07-01 2012-01-11 上海宝信软件股份有限公司 Realization method of configurable main and detailed data processing table
CN102566990A (en) * 2010-12-09 2012-07-11 北大方正集团有限公司 Method and device for performing data manipulation in Java application

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110307460A1 (en) * 2010-06-09 2011-12-15 Microsoft Corporation Navigating relationships among entities

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008952A (en) * 2007-01-30 2007-08-01 华为技术有限公司 Method and device for generating persistence layer
CN102314414A (en) * 2010-07-01 2012-01-11 上海宝信软件股份有限公司 Realization method of configurable main and detailed data processing table
CN102566990A (en) * 2010-12-09 2012-07-11 北大方正集团有限公司 Method and device for performing data manipulation in Java application

Also Published As

Publication number Publication date
CN104199907A (en) 2014-12-10

Similar Documents

Publication Publication Date Title
CN103944963B (en) Method of data synchronization, device, equipment and system
WO2016082513A1 (en) Method and device for prompting call request
CN104391870B (en) Logistics information acquisition methods and device
CN106020784A (en) Method and device for displaying application message, and terminal
CN104536935B (en) Calculate display methods, calculate edit methods and device
JP2023504070A (en) Circuit principle diagram check method, device and system
CN107423106A (en) The method and apparatus for supporting more frame grammars
CN107066172A (en) The document transmission method and device of mobile terminal
CN105068976A (en) Ticket information exhibition method and device
CN106202223A (en) Content collection method, device and for collecting the device of content in application program
KR20160048708A (en) Recognition method and apparatus for communication message
CN104636164B (en) Start page generation method and device
CN105354284B (en) Processing method and processing device, short message recognition methods and the device of template
CN107342082A (en) Audio-frequency processing method, device and audio-frequence player device based on interactive voice
CN105447109A (en) Key word searching method and apparatus
CN105550643A (en) Medical term recognition method and device
CN103916940A (en) Method and device for acquiring photographing position
CN103914520A (en) Data query method, terminal equipment and server
CN104462296A (en) File managing method and device and terminal
CN105183571A (en) Function calling method and device
CN104199907B (en) Insert the method and device of data
KR101787918B1 (en) Search method, apparatus, program and recording medium
CN104681049B (en) The display methods and device of prompt message
CN107506496A (en) Scrap cleaning method, device and computer-readable recording medium
CN104765646B (en) Component call method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 511446 Guangzhou City, Guangdong Province, Panyu District, South Village, Huambo Business District Wanda Plaza, block B1, floor 28

Applicant after: Guangzhou Huaduo Network Technology Co., Ltd.

Address before: 510655, Guangzhou, Whampoa Avenue, No. 2, creative industrial park, building 3-08,

Applicant before: Guangzhou Huaduo Network Technology Co., Ltd.

GR01 Patent grant
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20141210

Assignee: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Assignor: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

Contract record no.: X2021980000151

Denomination of invention: Method and device for inserting data

Granted publication date: 20170825

License type: Common License

Record date: 20210107