CN108710504A - Database operation method and device - Google Patents
Database operation method and device Download PDFInfo
- Publication number
- CN108710504A CN108710504A CN201710229947.3A CN201710229947A CN108710504A CN 108710504 A CN108710504 A CN 108710504A CN 201710229947 A CN201710229947 A CN 201710229947A CN 108710504 A CN108710504 A CN 108710504A
- Authority
- CN
- China
- Prior art keywords
- data
- database
- class
- tables
- interface
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
Abstract
A kind of database operation method of present invention offer and device, wherein method include:The attribute of tables of data is described by marking note, while defining minimum POJO abstract class and realizing serializing by self-defined annotation database and tables of data;Whether in Test database comprising tables of data tables of data is created if not including;The incoming POJO classes of detection, are added synchrolock, all properties of the table and field of reflected P OJO classes, and Property Name and attribute respective value are added in HashMap successively, are operated to data.Database operation method and device provided by the invention can reach and write many places at one and share, effectively increase the efficiency of database manipulation, easy to maintain and extension.
Description
Technical field
The present invention relates to Android treatment technologies more particularly to a kind of database operation methods and device.
Background technology
Android (Android) is a kind of freedom based on Linux and the operating system of open source code, is mainly used for moving
Dynamic equipment by Google companies and open mobile phone alliance leader and is developed such as smart mobile phone and tablet computer.With Android
The continuous development of technology, application range are also more carried out moonlight, are gradually expanded on other field, such as TV, digital camera, game
Machine etc. becomes one of most widely used operating system.
Android uses increasing income, unrelated with operating system SQL (Structured Query Language, structure
Change query language) database-SQLite.SQLite is a light-weight database, its design object is Embedded, is accounted for
It is very low with resource, it is only necessary to which that the memory of hundreds of K is with regard to much of that.
In existing Android database manipulations API (Application Programming Interface, using journey
Sequence programming interface) although in provide SQLiteOpenHelper classes, concrete operations also need to carry out complicated extension, no
Can reach write at one many places share, very time-consuming and laborious, inefficiency, the effect that easy care is not achieved, easily extends.
Invention content
A kind of database operation method of present invention offer and device, to solve the time-consuming expense of Data expansion in the prior art
The technical issues of power, inefficiency.
The present invention provides a kind of database operation method, including:
Self-defined annotation database and tables of data describe the attribute of tables of data by marking note, while defining most
Small POJO abstract class simultaneously realizes serializing;
Whether in Test database comprising tables of data tables of data is created if not including;
The incoming POJO classes of detection are added synchrolock, all properties of the table and field of reflected P OJO classes, and will belong to successively
Property title and attribute respective value are added in HashMap, are operated to data.
Further, self-defined annotation database and tables of data describe the attribute of tables of data by marking note, together
Shi Dingyi minimum POJO abstract class simultaneously realizes serializing, including:
Self-defined@interface explain class table id, and it is action scope FIELD that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME;
Self-defined@interface explain class table name, and it is TYPE that its range@Target, which are arranged, its@Retention is arranged
For RetentionPolicy.RUNTIME, and provide the function for returning to table name;
Self-defined@interface explain class database-name, and it is TYPE that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME, and provides the function of returned data library name;
Model abstract class is defined, realizes serializing interface, and provide abstract method.
Further, further include whether comprising before tables of data in Test database:
SQLiteOpenHelper is inherited, realizes the establishment and update of database;
Database attended operation interface class is defined, the interface class includes at least one of following:Database create, close,
Transaction management, insertion, deletion, update, inquiry;
Based on the API that Andriod is provided, the database attended operation interface class is realized.
Further, before the incoming POJO classes of detection, further include;
It defines and realizes that data bank service handles general-purpose interface class, and return to general type, the data bank service processing is general
Interface class includes at least one of following:It is inserted into, deletes, update, inquiring.
Further, it detects incoming POJO classes, is added synchrolock, all properties of the table and field of reflected P OJO classes,
And Property Name and attribute respective value are added in HashMap successively, data are operated, including:
General-purpose interface class is handled according to the data bank service of calling, determines the type of data manipulation;
The incoming POJO classes of detection, are added synchrolock, all properties of the table and field of reflected P OJO classes;
Property Name and attribute respective value are added in HashMap successively;
According to the type of the data manipulation, corresponding database attended operation interface class is called;
After the completion of operation, database connection is closed, implementing result is returned into user.
The present invention also provides a kind of database manipulation devices, including:
Definition module is used for self-defined annotation database and tables of data, and the attribute of tables of data is retouched by marking note
It states, while defining minimum POJO abstract class and realizing serializing;
Detection module, for whether comprising tables of data creating tables of data if not including in Test database;
Synchrolock, the table of reflected P OJO classes and all categories of field are added for detecting incoming POJO classes in operation module
Property, and Property Name and attribute respective value are added in HashMap successively, data are operated.
Further, the definition module is specifically used for:
Self-defined@interface explain class table id, and it is action scope FIELD that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME;
Self-defined@interface explain class table name, and it is TYPE that its range@Target, which are arranged, its@Retention is arranged
For RetentionPolicy.RUNTIME, and provide the function for returning to table name;
Self-defined@interface explain class database-name, and it is TYPE that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME, and provides the function of returned data library name;
Model abstract class is defined, realizes serializing interface, and provide abstract method.
Further, the detection module is additionally operable to:
Whether comprising before tables of data in Test database, SQLiteOpenHelper is inherited, realizes the wound of database
It builds and updates;
Database attended operation interface class is defined, the interface class includes at least one of following:Database create, close,
Transaction management, insertion, deletion, update, inquiry;
Based on the API that Andriod is provided, the database attended operation interface class is realized.
Further, the detection module is additionally operable to:
It defines and realizes that data bank service handles general-purpose interface class, and return to general type, the data bank service processing is general
Interface class includes at least one of following:It is inserted into, deletes, update, inquiring.
Further, the operation module is specifically used for:
General-purpose interface class is handled according to the data bank service of calling, determines the type of data manipulation;
The incoming POJO classes of detection, are added synchrolock, all properties of the table and field of reflected P OJO classes;
Property Name and attribute respective value are added in HashMap successively;
According to the type of the data manipulation, corresponding database attended operation interface class is called;
After the completion of operation, database connection is closed, implementing result is returned into user.
Database operation method and device provided by the invention, by self-defined annotation database and tables of data, by data
The attribute of table is described by marking note, while being defined minimum POJO abstract class and being realized serializing, is in Test database
It is no to create tables of data if not including comprising tables of data, incoming POJO classes are detected, synchrolock, the table of reflected P OJO classes is added
With all properties of field, and Property Name and attribute respective value are added in HashMap successively, data are operated,
It can reach and write many places at one and share, effectively increase the efficiency of database manipulation, easy to maintain and extension.
Description of the drawings
Fig. 1 is the flow chart for the database operation method that the embodiment of the present invention one provides;
Fig. 2 is the flow chart of database operation method provided by Embodiment 2 of the present invention;
Fig. 3 is the structure diagram for the database manipulation device that the embodiment of the present invention three provides.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
The every other embodiment obtained without creative efforts, shall fall within the protection scope of the present invention.
The term used in the embodiment of the present application is the purpose only merely for description specific embodiment, is not intended to be limiting
The present invention.The "an" of used singulative, " described " and "the" are also intended to including most shapes in the embodiment of the present application
Formula, unless context clearly shows that other meanings.
It should be appreciated that term "and/or" used herein is only a kind of incidence relation of description affiliated partner, indicate
There may be three kinds of relationships, for example, A and/or B, can indicate:Individualism A, exists simultaneously A and B, individualism B these three
Situation.In addition, character "/" herein, it is a kind of relationship of "or" to typically represent forward-backward correlation object.
Depending on context, word as used in this " if ", " if " can be construed to " ... when " or
" when ... " or " in response to determination " or " in response to detection ".Similarly, context is depended on, phrase " if it is determined that " or " such as
Fruit detect (condition or event of statement) " can be construed to " when determining " or " in response to determination " or " when detection (statement
Condition or event) when " or " in response to detection (condition or event of statement) ".
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
Including so that commodity or system including a series of elements include not only those elements, but also include not clear
The other element listed, or further include for this commodity or the intrinsic element of system.In the feelings not limited more
Under condition, the element that is limited by sentence "including a ...", it is not excluded that including the element commodity or system in also
There are other identical elements.
Embodiment one
The embodiment of the present invention one provides a kind of database operation method.Fig. 1 is the database that the embodiment of the present invention one provides
The flow chart of operating method.As shown in Figure 1, the method in the present embodiment, may include:
Step 101, self-defined annotation database and tables of data describe the attribute of tables of data by marking note, together
Shi Dingyi minimum POJO abstract class simultaneously realizes serializing.
Note technology (Annotation), is called metadata, is a kind of other explanation of code level.It is JDK1.5 and after
The characteristic that version introduces, and class, interface, to enumerate be in the same level.It can state packet, class, field, method,
Before local variable, method parameter etc., for being illustrated to these elements, annotation.
In the present embodiment, self-defined note can be carried out to database-name, data table name and tables of data ID, each
It can include one or more tables of data in database, can include one or more fields in each tables of data.Wherein, data
Library name and data table name are respectively the title of database and tables of data, and tables of data ID can be the name of each field in tables of data
Claim or identifies.
The attribute of tables of data can be described by marking note, specifically, self-defined@Targe and@can be passed through
Retention etc. realizes the note of tables of data.
After self-defined annotation database and tables of data, minimum POJO (Plain Ordinary JAVA can be defined
Object, simple JAVA object, practical is exactly common JAVABeans, is in order to avoid obscuring created abbreviation with EJB)
Abstract class simultaneously realizes serializing.It defines abstract class and realizes that serializing belongs to the prior art, and will not be described here in detail.
Whether in step 102, Test database comprising tables of data tables of data is created if not including.
If including tables of data in database, step 103 can be directly entered and carry out data manipulation.
Preferably, Android databases can be combined first whether comprising before tables of data in Test database
API writes database connection, the updating unit class of minimum unit.Specifically, it in conjunction with the API of Android databases, writes most
The database connection of junior unit, updating unit class, may include following three steps:
Step a1, SQLiteOpenHelper is inherited, realizes the establishment and update of database.
Wherein, SQLiteOpenHelper is the database assisted class that Android platform provides, for creating or opening number
According to library.
Step b1, database attended operation interface class is defined, the interface class includes at least one of following:Database is created
Build, close, transaction management, insertion, deletion, update, inquiry.
Specifically, the API that can be provided in conjunction with Android defines database attended operation interface class, database connection behaviour
It includes that database is created, closed, transaction management (transaction management includes unlatching, submission, rollback, end etc. again), inserting to make interface class
Enter, delete, update, inquire.It is last to provide an execution Sql sentence again to extend for greater flexibility.
Step c1, the API provided based on Andriod is realized the database attended operation interface class, that is, realizes step b1
Defined in interface class.
Step a1 is the establishment and update for realizing database, and step b1 and step c1 are for realizing in database
The establishment and update of various tables of data.
In the API for combining Android databases, the database connection of minimum unit is write, after updating unit class, it can be with
Carry out subsequent data manipulation.
The incoming POJO classes of step 103, detection, addition synchrolock, all properties of the table and field of reflected P OJO classes, and
Property Name and attribute respective value are added in HashMap successively, data are operated.
This step for realizing data concrete operations, such as data insertion, deletion, update, inquiry etc..When needs pair
When data are operated, for example, need be inserted into a data when, step 103 may be used to realize.
Correspondingly, before the incoming POJO classes of detection, it can also define and realize that data bank service handles general-purpose interface
Class, and general type is returned, the data bank service processing general-purpose interface class includes at least one of following:It is inserted into, deletes, updates, looks into
It askes.
The general types of JAVA are the new features of JAVA SE 1.5, and the essence of general type is parameterized type, that is to say, that operated
Data type is designated as a parameter.This parameter type can be used in the establishment of class, interface and method, be referred to as general
Type class, general type interface, general type method.
The insertion, deletion, update, inquiry operation can be directed to single, can also be the operation for a plurality of data.
Preferably, the POJO classes that the detection in step 103 is passed to, are added synchrolock, the table and field of reflected P OJO classes
All properties, and Property Name and attribute respective value are added in HashMap successively, data are operated, can be wrapped
Include following steps:
Step a2, general-purpose interface class is handled according to the data bank service of calling, determines the type of data manipulation.
The type of the data manipulation can be any one in insertion, deletion, update, inquiry.
Step b2, synchrolock, all properties of the table and field of reflected P OJO classes are added in the incoming POJO classes of detection.
Wherein, each JAVA object has and only there are one synchrolocks, at any time, at most only a thread is allowed to gather around
There is this synchrolock, when consumer thread attempts to execute the code block to carry synchronized (this) labels, consumption
Person's thread must first obtain the lock of the Stack objects of this keywords reference.
After synchrolock is added, reflex mechanism can be utilized to obtain all properties of the table and field of POJO classes.The table and
The all properties of field can be all properties of tables of data defined in step 101 and wherein field.
JAVA reflex mechanisms are, for any one class, can to know all properties of this class in operating status
And method;For any one object, its any one method and attribute can be called;The information of this dynamic access with
And the function of the method for dynamic call object is known as the reflex mechanism of JAVA language.
Step c2, Property Name and attribute respective value are added in HashMap successively.
Step d2, according to the type of the data manipulation, corresponding database attended operation interface class is called.
HashMap is the realization of the Map interfaces based on Hash table, and Property Name and attribute respective value are added to
After HashMap, corresponding database attended operation interface class, i.e. the database attended operation realized in step c1 can be called to connect
Mouthful class realizes data manipulation.What the type of data manipulation is, the type of the database attended operation interface class of calling is exactly
What.For example, if it is a data to be inserted into, the type of data manipulation is exactly to be inserted into, the number of calling being just for insertion into
According to library attended operation interface class.
Step e2, after the completion of operation, database connection is closed, implementing result is returned into user.
After realizing data manipulation by step 103, outward service processing class can also be further defined, and encapsulate
Operation in step 103 is realized and is externally called.
In practical applications, user can utilize and explain dynamic construction database-name, data table name, Field ID etc.,
The behavior that all database manipulations are handled using reflex mechanism writes base class using the general type asterisk wildcards of JAVA, utilizes design pattern
The interface that externally provides is provided, later, processing data is returned into View and shows, it is scattered to avoid establishment database, tables of data,
Make database data processing more independent, modularization, reaches and write many places use at one, greatly improve development efficiency and Modle
With the decoupling effect of View.
Database operation method provided in this embodiment, by self-defined annotation database and tables of data, by tables of data
Whether attribute is described by marking note, while being defined minimum POJO abstract class and being realized serializing, wrapped in Test database
Containing tables of data, if not including, tables of data is created, detects incoming POJO classes, synchrolock, the table and word of reflected P OJO classes is added
The all properties of section, and Property Name and attribute respective value are added in HashMap successively, data are operated, it can
Reach and write many places at one and share, effectively increases the efficiency of database manipulation, easy to maintain and extension.
Embodiment two
Second embodiment of the present invention provides a kind of database operation methods.Fig. 2 is database provided by Embodiment 2 of the present invention
The flow chart of operating method.As shown in Fig. 2, the method in the present embodiment, may include:
Step 201, self-defined@interface explain class table id, and it is action scope FIELD that its range@Target, which are arranged, if
It is RetentionPolicy.RUNTIME to set its@Retention.
Specifically, table id (TableId) can be the title or mark of the field in tables of data, self-defined interface
Class table id is explained, it is that action scope FIELD ,@Target are used to illustrate that the note can be declared at that its range@Target, which are arranged,
Before a little elements ,@Target are action scope FIELD, illustrate that the note can only be declared before the field of a class, that is, are used as one
The note of a field.
It is RetentionPolicy.RUNTIME that its@Retention, which is arranged, and@Retention are for illustrating the note class
Life cycle, RetentionPolicy.RUNTIME indicate explain be retained in program operation during, reflection can be passed through at this time
Obtain all notes being defined in some class, that is to say, that the information of note is retained in class files (byte code files)
In, when program compiles, can be retained at runtime, so that they can be read with the mode of reflection by virtual machine.
Step 202, self-defined@interface explain class table name, and it is TYPE that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME, and provides the function for returning to table name.
Wherein, the table name can be tables of data title, and it is TYPE that its range Target, which is arranged, indicate the note only
It can be declared before a class.
Step 203, self-defined@interface explain class database-name, and it is TYPE, setting that its range@Target, which are arranged,
Its@Retention is RetentionPolicy.RUNTIME, and provides the function of returned data library name.
Step 204 defines Model abstract class, realizes serializing interface, and provide abstract method.
Abstract method can be returned to the Sql sentences for creating corresponding subclass table by subclass override.
In the present embodiment, self-defined annotation database and tables of data are completed by step 201 to step 204, by data
The attribute of table is described by marking note, while being defined minimum POJO abstract class and being realized serializing, is equivalent to and is completed reality
Apply a kind of step 101 of example.
Whether in step 205, Test database comprising tables of data tables of data is created if not including.
The incoming POJO classes of step 206, detection, addition synchrolock, all properties of the table and field of reflected P OJO classes, and
Property Name and attribute respective value are added in HashMap successively, data are operated.
Step 205 in the present embodiment is similar to step 103 with the step 102 in embodiment one to step 206, herein not
It repeats again.
Database operation method provided in this embodiment, by being noted to database-name, data table name, table id etc.
Solution, the attribute of claim data library name, data table name, table id etc. can preferably complete database-name, data table name
Claim, the establishment and storage of table id, ensures the independent and modularization of database data processing.
Embodiment three
The embodiment of the present invention three provides a kind of database manipulation device.Fig. 3 is the database that the embodiment of the present invention three provides
The structure diagram of operating device.As shown in figure 3, the device in the present embodiment, may include:
Definition module 301, be used for self-defined annotation database and tables of data, by the attribute of tables of data by mark explain come
Description, while defining minimum POJO abstract class and realizing serializing;
Detection module 302, for whether comprising tables of data creating tables of data if not including in Test database;
Synchrolock, the table of reflected P OJO classes and the institute of field is added for detecting incoming POJO classes in operation module 303
There is attribute, and Property Name and attribute respective value are added in HashMap successively, data are operated.
Database manipulation device in the present embodiment, can be used for executing the database manipulation described in any of the above-described embodiment
Method, specific implementation principle may refer to above-described embodiment, and details are not described herein again.
Database manipulation device provided in this embodiment, by self-defined annotation database and tables of data, by tables of data
Whether attribute is described by marking note, while being defined minimum POJO abstract class and being realized serializing, wrapped in Test database
Containing tables of data, if not including, tables of data is created, detects incoming POJO classes, synchrolock, the table and word of reflected P OJO classes is added
The all properties of section, and Property Name and attribute respective value are added in HashMap successively, data are operated, it can
Reach and write many places at one and share, effectively increases the efficiency of database manipulation, easy to maintain and extension.
Further, the definition module 301 is specifically used for:
Self-defined@interface explain class table id, and it is action scope FIELD that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME;
Self-defined@interface explain class table name, and it is TYPE that its range@Target, which are arranged, its@Retention is arranged
For RetentionPolicy.RUNTIME, and provide the function for returning to table name;
Self-defined@interface explain class database-name, and it is TYPE that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME, and provides the function of returned data library name;
Model abstract class is defined, realizes serializing interface, and provide abstract method.
Further, the detection module 302 is additionally operable to:
Whether comprising before tables of data in Test database, SQLiteOpenHelper is inherited, realizes the wound of database
It builds and updates;
Database attended operation interface class is defined, the interface class includes at least one of following:Database create, close,
Transaction management, insertion, deletion, update, inquiry;
Based on the API that Andriod is provided, the database attended operation interface class is realized.
Further, the detection module 302 is additionally operable to:
It defines and realizes that data bank service handles general-purpose interface class, and return to general type, the data bank service processing is general
Interface class includes at least one of following:It is inserted into, deletes, update, inquiring.
Further, the operation module 303 is specifically used for:
General-purpose interface class is handled according to the data bank service of calling, determines the type of data manipulation;
The incoming POJO classes of detection, are added synchrolock, all properties of the table and field of reflected P OJO classes;
Property Name and attribute respective value are added in HashMap successively;
According to the type of the data manipulation, corresponding database attended operation interface class is called;
After the completion of operation, database connection is closed, implementing result is returned into user.
Finally it should be noted that:The above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent
Present invention has been described in detail with reference to the aforementioned embodiments for pipe, it will be understood by those of ordinary skill in the art that:Its according to
So can with technical scheme described in the above embodiments is modified, either to which part or all technical features into
Row equivalent replacement;And these modifications or replacements, various embodiments of the present invention technology that it does not separate the essence of the corresponding technical solution
The range of scheme.
Claims (10)
1. a kind of database operation method, which is characterized in that including:
The attribute of tables of data is described by marking note, while defining minimum by self-defined annotation database and tables of data
POJO abstract class simultaneously realizes serializing;
Whether in Test database comprising tables of data tables of data is created if not including;
The incoming POJO classes of detection, addition synchrolock, all properties of the table and field of reflected P OJO classes, and successively by attribute-name
Claim and attribute respective value is added in HashMap, data are operated.
2. according to the method described in claim 1, it is characterized in that, self-defined annotation database and tables of data, by tables of data
Attribute is described by marking note, while being defined minimum POJO abstract class and being realized serializing, including:
Self-defined@interface explain class table id, and it is action scope FIELD that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME;
Self-defined@interface explain class table name, and it is TYPE that its range@Target, which are arranged, its@Retention, which is arranged, is
RetentionPolicy.RUNTIME, and the function for returning to table name is provided;
Self-defined@interface explain class database-name, and it is TYPE that its range@Target, which are arranged, its@Retention is arranged
For RetentionPolicy.RUNTIME, and provide the function of returned data library name;
Model abstract class is defined, realizes serializing interface, and provide abstract method.
3. method according to claim 1 or 2, which is characterized in that before whether including tables of data in Test database,
Further include:
SQLiteOpenHelper is inherited, realizes the establishment and update of database;
Database attended operation interface class is defined, the interface class includes at least one of following:Database is created, is closed, affairs
Management is inserted into, deletes, update, inquiring;
Based on the API that Andriod is provided, the database attended operation interface class is realized.
4. according to the method described in claim 3, it is characterized in that, before the incoming POJO classes of detection, further include;
It defines and realizes that data bank service handles general-purpose interface class, and return to general type, the data bank service handles general-purpose interface
Class includes at least one of following:It is inserted into, deletes, update, inquiring.
5. according to the method described in claim 4, it is characterized in that, the POJO classes that detection is passed to, are added synchrolock, reflected P OJO
The table of class and all properties of field, and Property Name and attribute respective value are added in HashMap successively, data are carried out
Operation, including:
General-purpose interface class is handled according to the data bank service of calling, determines the type of data manipulation;
The incoming POJO classes of detection, are added synchrolock, all properties of the table and field of reflected P OJO classes;
Property Name and attribute respective value are added in HashMap successively;
According to the type of the data manipulation, corresponding database attended operation interface class is called;
After the completion of operation, database connection is closed, implementing result is returned into user.
6. a kind of database manipulation device, which is characterized in that including:
Definition module is used for self-defined annotation database and tables of data, the attribute of tables of data is described by marking note, together
Shi Dingyi minimum POJO abstract class simultaneously realizes serializing;
Detection module, for whether comprising tables of data creating tables of data if not including in Test database;
Synchrolock is added for detecting incoming POJO classes in operation module, all properties of the table and field of reflected P OJO classes,
And Property Name and attribute respective value are added in HashMap successively, data are operated.
7. device according to claim 6, which is characterized in that the definition module is specifically used for:
Self-defined@interface explain class table id, and it is action scope FIELD that its range@Target, which are arranged, its@is arranged
Retention is RetentionPolicy.RUNTIME;
Self-defined@interface explain class table name, and it is TYPE that its range@Target, which are arranged, its@Retention, which is arranged, is
RetentionPolicy.RUNTIME, and the function for returning to table name is provided;
Self-defined@interface explain class database-name, and it is TYPE that its range@Target, which are arranged, its@Retention is arranged
For RetentionPolicy.RUNTIME, and provide the function of returned data library name;
Model abstract class is defined, realizes serializing interface, and provide abstract method.
8. the device described according to claim 6 or 7, which is characterized in that the detection module is additionally operable to:
Whether comprising before tables of data in Test database, inherit SQLiteOpenHelper, realize database establishment and
Update;
Database attended operation interface class is defined, the interface class includes at least one of following:Database is created, is closed, affairs
Management is inserted into, deletes, update, inquiring;
Based on the API that Andriod is provided, the database attended operation interface class is realized.
9. device according to claim 8, which is characterized in that the detection module is additionally operable to:
It defines and realizes that data bank service handles general-purpose interface class, and return to general type, the data bank service handles general-purpose interface
Class includes at least one of following:It is inserted into, deletes, update, inquiring.
10. device according to claim 9, which is characterized in that the operation module is specifically used for:
General-purpose interface class is handled according to the data bank service of calling, determines the type of data manipulation;
The incoming POJO classes of detection, are added synchrolock, all properties of the table and field of reflected P OJO classes;
Property Name and attribute respective value are added in HashMap successively;
According to the type of the data manipulation, corresponding database attended operation interface class is called;
After the completion of operation, database connection is closed, implementing result is returned into user.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710229947.3A CN108710504A (en) | 2017-04-10 | 2017-04-10 | Database operation method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710229947.3A CN108710504A (en) | 2017-04-10 | 2017-04-10 | Database operation method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108710504A true CN108710504A (en) | 2018-10-26 |
Family
ID=63866140
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710229947.3A Pending CN108710504A (en) | 2017-04-10 | 2017-04-10 | Database operation method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108710504A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109471869A (en) * | 2018-12-27 | 2019-03-15 | 山东浪潮商用系统有限公司 | A kind of method and system that local data base upgrades automatically |
CN112540995A (en) * | 2020-11-11 | 2021-03-23 | 特劢丝软件科技(上海)有限公司 | Data updating method, electronic device and storage medium |
CN113448995A (en) * | 2020-03-25 | 2021-09-28 | 北京沃东天骏信息技术有限公司 | Database operation method, device and system, electronic equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050262041A1 (en) * | 2004-05-21 | 2005-11-24 | Bea Systems, Inc. | Systems and methods for plain old java object (POJO) persistence |
CN101339559A (en) * | 2008-07-18 | 2009-01-07 | 北京航空航天大学 | Long lasting implementing method for data |
CN103020064A (en) * | 2011-09-20 | 2013-04-03 | 佳都新太科技股份有限公司 | Method and configuration for generating query condition in annotation way |
CN104679903A (en) * | 2015-03-20 | 2015-06-03 | 亚信科技(南京)有限公司 | Method and device for operating data sheets |
CN105159920A (en) * | 2015-07-28 | 2015-12-16 | 卡斯柯信号有限公司 | Attribute tag based database access method |
CN105354073A (en) * | 2015-10-27 | 2016-02-24 | 中通服公众信息产业股份有限公司 | Android system based standalone application networking method and system |
CN105843609A (en) * | 2016-03-18 | 2016-08-10 | 浪潮软件集团有限公司 | MVC frame based on Spring and MyBatis |
CN106302442A (en) * | 2016-08-12 | 2017-01-04 | 广州慧睿思通信息科技有限公司 | A kind of network communication packet analytic method based on Java language |
-
2017
- 2017-04-10 CN CN201710229947.3A patent/CN108710504A/en active Pending
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050262041A1 (en) * | 2004-05-21 | 2005-11-24 | Bea Systems, Inc. | Systems and methods for plain old java object (POJO) persistence |
CN101339559A (en) * | 2008-07-18 | 2009-01-07 | 北京航空航天大学 | Long lasting implementing method for data |
CN103020064A (en) * | 2011-09-20 | 2013-04-03 | 佳都新太科技股份有限公司 | Method and configuration for generating query condition in annotation way |
CN104679903A (en) * | 2015-03-20 | 2015-06-03 | 亚信科技(南京)有限公司 | Method and device for operating data sheets |
CN105159920A (en) * | 2015-07-28 | 2015-12-16 | 卡斯柯信号有限公司 | Attribute tag based database access method |
CN105354073A (en) * | 2015-10-27 | 2016-02-24 | 中通服公众信息产业股份有限公司 | Android system based standalone application networking method and system |
CN105843609A (en) * | 2016-03-18 | 2016-08-10 | 浪潮软件集团有限公司 | MVC frame based on Spring and MyBatis |
CN106302442A (en) * | 2016-08-12 | 2017-01-04 | 广州慧睿思通信息科技有限公司 | A kind of network communication packet analytic method based on Java language |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109471869A (en) * | 2018-12-27 | 2019-03-15 | 山东浪潮商用系统有限公司 | A kind of method and system that local data base upgrades automatically |
CN113448995A (en) * | 2020-03-25 | 2021-09-28 | 北京沃东天骏信息技术有限公司 | Database operation method, device and system, electronic equipment and storage medium |
CN112540995A (en) * | 2020-11-11 | 2021-03-23 | 特劢丝软件科技(上海)有限公司 | Data updating method, electronic device and storage medium |
CN112540995B (en) * | 2020-11-11 | 2022-12-02 | 上海赛美特软件科技有限公司 | Data updating method, electronic device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Carlsson et al. | SICStus Prolog—the first 25 years | |
US7293254B2 (en) | Extensibility application programming interface and framework for meta-model objects | |
US9575736B2 (en) | Advanced interactive command-line front-end for graph analysis systems | |
CN108027722A (en) | The dynamically renewal application in compiling and deployment | |
CN109032825B (en) | Fault injection method, device and equipment | |
US20150143339A1 (en) | Callpath finder | |
JPH1040087A (en) | Method for handling data model to be used for software engineering | |
US10552127B2 (en) | Method and system for developing relation-context specific software applications | |
CN103443761A (en) | Unchanged object mamagement | |
US10310827B2 (en) | Flow-based scoping | |
WO2024045382A1 (en) | Implementation of reflective mechanism in blockchain | |
CN108319711A (en) | Transaction consistency test method, device, storage medium and the equipment of database | |
US7698695B2 (en) | Search technique for design patterns in Java source code | |
CN108710504A (en) | Database operation method and device | |
CN108920566B (en) | Method, device and equipment for operating SQLite database | |
CN111240772B (en) | Block chain-based data processing method, device and storage medium | |
KR20110099214A (en) | Type descriptor management for frozen objects | |
CN112069052A (en) | Abnormal object detection method, device, equipment and storage medium | |
CN114588638A (en) | Method for developing game based on Lua language and program development device | |
CN112052048B (en) | Data loading method and device, equipment and storage medium | |
CN117234517A (en) | Interface parameter verification method, device, equipment and storage medium | |
CN116069937A (en) | Intelligent contract classification method and device based on neural network and computer equipment | |
Cohen et al. | EventScript: an event-processing language based on regular expressions with actions | |
US20100180269A1 (en) | Domains with polymorphic type implementations | |
US10657476B2 (en) | Just in time compilation (JIT) for business process execution |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20181026 |