CN110333883A - A kind of method and device updating perdurable data - Google Patents

A kind of method and device updating perdurable data Download PDF

Info

Publication number
CN110333883A
CN110333883A CN201910472372.7A CN201910472372A CN110333883A CN 110333883 A CN110333883 A CN 110333883A CN 201910472372 A CN201910472372 A CN 201910472372A CN 110333883 A CN110333883 A CN 110333883A
Authority
CN
China
Prior art keywords
instance
updated
field
value
whole fields
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.)
Granted
Application number
CN201910472372.7A
Other languages
Chinese (zh)
Other versions
CN110333883B (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.)
Xiamen Wangsu Co Ltd
Original Assignee
Xiamen Wangsu 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 Xiamen Wangsu Co Ltd filed Critical Xiamen Wangsu Co Ltd
Priority to CN201910472372.7A priority Critical patent/CN110333883B/en
Publication of CN110333883A publication Critical patent/CN110333883A/en
Application granted granted Critical
Publication of CN110333883B publication Critical patent/CN110333883B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a kind of method and devices for updating perdurable data, wherein the described method includes: obtaining first instance, wherein the first instance includes whole fields of object to be updated and the value of field to be updated;Whole fields of the object to be updated and the value of each field are obtained from storage equipment, and is stored in second instance;The value of field to be updated described in the second instance is updated to the value of field to be updated described in the first instance;Updated second instance is persisted in the storage equipment.The operation that the present invention updates perdurable data uses intelligent control, it is possible to reduce cumbersome repetition judges that efficient completion data update manually.

Description

A kind of method and device updating perdurable data
Technical field
The present invention relates to field of computer technology, in particular to a kind of method and device for updating perdurable data.
Background technique
Developer often inevitably needs by data persistence into disk when carrying out programming at present, And data are increased, deleted, modified or are inquired repeatedly.Wherein, when execution " modification " operates, often inevitably It needs to modify for wherein one or more fields, remaining field retains original value.
It usually modifies manually for the modification of perdurable data at present, repeats work there is a large amount of during modification Make, manual modification mode is comparatively laborious, time-consuming effort.
Summary of the invention
In order to solve problems in the prior art, the embodiment of the invention provides a kind of methods and dress for updating perdurable data It sets.The technical solution is as follows:
In a first aspect, providing a kind of method for updating perdurable data, which comprises
Obtain first instance, wherein the first instance includes the whole fields and field to be updated of object to be updated Value;
Whole fields of the object to be updated and the value of each field are obtained from storage equipment, and is stored in second In entity;
The value of field to be updated described in the second instance is updated to field to be updated described in the first instance Value;
Updated second instance is persisted in the storage equipment.
Optionally, the step of acquisition first instance includes:
Obtain the parameter of entity class;
The first instance is generated based on the parameter.
Optionally, described to obtain whole fields of the object to be updated and the value of each field from storage equipment Step, comprising:
Whether the value for judging the identification field of object to be updated in the first instance is empty;
If it is, process terminates, whole fields of the object to be updated and each are otherwise obtained from storage equipment The value of a field.
Optionally, the value for judging the identification field of object to be updated in the first instance whether be empty step it Before, comprising:
The value of the identification field of object to be updated in the first instance is obtained by Java reflection mechanism.
Optionally, the value by field to be updated described in the second instance is updated to described in the first instance The step of value of field to be updated, comprising:
Whole fields in the first instance are obtained, and traverse whole fields;
It is not empty field if there is value, then is not empty field using described value as the field to be updated, and will The value of the field to be updated is assigned in the second instance field identical with the field to be updated.
Optionally, the step of whole fields obtained in the first instance, further includes:
Whether the data for judging the second instance are empty;
If it is, process terminates, whole fields in the first instance are otherwise obtained.
Second aspect, provides a kind of device for updating perdurable data, and described device includes:
First obtains module, for obtaining first instance, wherein the first instance includes whole words of object to be updated The value of section and field to be updated;
Second obtains module, for obtaining the whole fields and each field of the object to be updated from storage equipment Value, and be stored in second instance;
Update module, for the value of field to be updated described in the second instance to be updated to institute in the first instance State the value of field to be updated;
Persistence module, for updated second instance to be persisted in the storage equipment.
Optionally, described first module is obtained, is specifically used for:
Obtain the parameter of entity class;
The first instance is generated based on the parameter.
Optionally, described second module is obtained, is specifically used for:
Whether the value for judging the identification field of object to be updated in the first instance is empty;
If it is, process terminates, whole fields of the object to be updated and each are otherwise obtained from storage equipment The value of a field.
Optionally, described second module is obtained, also particularly useful for:
The value of the identification field of object to be updated in the first instance is obtained by Java reflection mechanism.
Optionally, the persistence module, is specifically used for:
Whole fields in the first instance are obtained, and traverse whole fields;
It is not empty field if there is value, then is not empty field using described value as the field to be updated, and will The value of the field to be updated is assigned in the second instance field identical with the field to be updated.
Optionally, the persistence module, also particularly useful for:
Whether the data for judging the second instance are empty;
If it is, process terminates, whole fields in the first instance are otherwise obtained.
The third aspect, provides a kind of computer equipment, and the computer equipment includes processor and memory, described to deposit Be stored at least one instruction, at least a Duan Chengxu, code set or instruction set in reservoir, at least one instruction, it is described extremely A few Duan Chengxu, the code set or instruction set are loaded as the processor and are executed to realize described in above-mentioned first aspect more The method of new perdurable data.
The embodiment of the present invention, can be by needing when updating perdurable data in the automatically derived first instance of intellectual analysis The field of update and the field for not needing update, and legacy data can be obtained automatically from storage equipment, save as second Entity, then the value of field to be updated in first instance is assigned to second instance, finally by updated second instance persistence Into storage equipment, the operation of the update perdurable data uses intelligent control, it is possible to reduce cumbersome repetition judges manually, institute It, can efficient completion data update with no matter object to be modified includes how many Field Count.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other Attached drawing.
Fig. 1 is a kind of flow chart of processing method of inquiring the price provided in an embodiment of the present invention;
Fig. 2 is a kind of structural block diagram of processing unit of inquiring the price provided in an embodiment of the present invention;
Fig. 3 is a kind of structural block diagram of computer equipment provided in an embodiment of the present invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention Formula is described in further detail.
The data being persisted in storage equipment are saved in the form of database table.It may include more in database table The data of a object, each object may include multiple fields, and each field has corresponding value (value).For example, object A packet The field included has id, f1, f2 and f3, and the value of these fields is respectively 1, a1, a2 and a3.Wherein, the id field in object For a record in the table of unique identification data library, namely it is used for unique identification an object.For with other words in object Duan Jinhang difference, is known as identification field for the id field in object here.When needing to modify the value of a certain field, such as by word The value of section f2 is changed to b2 by a2, can use the method provided in an embodiment of the present invention for updating perdurable data and modifies, has Body modification process is as described below.
It referring to Fig.1, is a kind of flow chart for the method for updating perdurable data provided in an embodiment of the present invention, this method tool Body includes the following steps.
Step 101, obtain first instance, wherein the first instance include object to be updated whole fields and to The value of more newer field.
The first instance is the entity of ENTITY (entity) class.Whole fields in first instance including object to be updated are believed Breath and the field to be updated value to be revised as, the value of remaining field are sky.For example, the id value of first instance is the value of 1, f2 Value for b2, f1 and f3 is sky.First instance intermediate value is not that empty field is the field for needing to update, and the field being worth for sky is The field updated is not needed.
It in an implementation, can be by manually in the parameter namely information to be updated of application layer input ENTITY class, this is to be updated Information includes the id of object to be updated, the value of field to be updated and field to be updated in the object to be updated.Getting this After information to be updated, first instance is generated.Optionally, the first instance being pre-created can also be directly acquired, the present invention Embodiment does not limit the mode for obtaining the first instance specifically.
Step 102, whole fields of the object to be updated and the value of each field are obtained from storage equipment, and protected There are in second instance.
After getting first instance, the mark of object to be updated in the first instance is obtained by Java reflection mechanism The value of id in the value namely first instance of field.Wherein, Java reflection mechanism is that one kind being capable of dynamic acquisition information and dynamic Call the function of object method.Whether the value for then judging the identification field of object to be updated in the first instance is empty.Such as Fruit is sky, illustrates that parameter transmitting is wrong, then process terminates, and whole words of the object to be updated are otherwise obtained from storage equipment The value of section and each field, and being stored in is all in the second instance of ENTITY class.For example, the di value in second instance is 1, The value of f1 is a1, and the value of f2 is a2, and the value of f3 is a3.
Step 103, by the value of field to be updated described in the second instance be updated to described in the first instance to The value of more newer field.
After obtaining second instance, judge whether the data of the second instance are empty, if it is, process terminates, Otherwise the value of field to be updated described in the second instance is updated to the value of field to be updated described in the first instance. Specific more new technological process becomes: obtaining whole fields in the first instance, and traverses whole fields;It is not if there is value Described value is not then empty field by empty field as the field to be updated, and by the value assignment of the field to be updated To field identical with the field to be updated in the second instance.For example, only the value of f2 is not empty in first instance, The value b2 of f2 is then assigned to the f2 in second instance, the value of f2 is also just revised as b2 by a2, and the value of remaining field is constant, completes Update operation.
In an implementation, whole fields in the first instance can be obtained by Introspection and reflection mechanism.Wherein, Introspection is a kind of default process method of the Java language to Bean generic attribute and event, passes through get (acquisition) method Or set (modification) method accesses object properties.
Step 104, updated second instance is persisted in the storage equipment.
After having updated second instance, second instance is saved in can be in the storage equipment of persistence, such as disk, It completes data persistence.
The embodiment of the present invention is not limited to the type of entity, has lower coupling, such as can be entity cat or entity dog, should Entity may include any type of attribute, will not need to do extra process because of entity difference.
The embodiment of the present invention, can be by needing when updating perdurable data in the automatically derived first instance of intellectual analysis The field of update and the field for not needing update, and legacy data can be obtained automatically from storage equipment, save as second Entity, then the value of field to be updated in first instance is assigned to second instance, finally by updated second instance persistence Into storage equipment, the operation of the update perdurable data uses intelligent control, it is possible to reduce cumbersome repetition judges manually, institute It, can efficient completion data update with no matter object to be modified includes how many Field Count.
Referring to Fig. 2, for a kind of structural block diagram for the device for updating perdurable data provided in an embodiment of the present invention, the dress It sets and includes:
First obtains module 201, for obtaining first instance, wherein the first instance includes the complete of object to be updated The value of portion's field and field to be updated;
Second obtains module 202, for obtaining whole fields of the object to be updated and each from storage equipment The value of field, and be stored in second instance;
Update module 203, for the value of field to be updated described in the second instance to be updated to the first instance Described in field to be updated value;
Persistence module 204, for updated second instance to be persisted in the storage equipment.
Preferably, described first module 201 is obtained, is specifically used for:
Obtain the parameter of entity class;
The first instance is generated based on the parameter.
Preferably, described second module 202 is obtained, is specifically used for:
Whether the value for judging the identification field of object to be updated in the first instance is empty;
If it is, process terminates, whole fields of the object to be updated and each are otherwise obtained from storage equipment The value of a field.
Preferably, described second module 202 is obtained, also particularly useful for:
The value of the identification field of object to be updated in the first instance is obtained by Java reflection mechanism.
Preferably, the persistence module 203, is specifically used for:
Whole fields in the first instance are obtained, and traverse whole fields;
It is not empty field if there is value, then is not empty field using described value as the field to be updated, and will The value of the field to be updated is assigned in the second instance field identical with the field to be updated.
Preferably, the persistence module 204, also particularly useful for:
Whether the data for judging the second instance are empty;
If it is, process terminates, whole fields in the first instance are otherwise obtained.
The embodiment of the present invention, can be by needing when updating perdurable data in the automatically derived first instance of intellectual analysis The field of update and the field for not needing update, and legacy data can be obtained automatically from storage equipment, save as second Entity, then the value of field to be updated in first instance is assigned to second instance, finally by updated second instance persistence Into storage equipment, the operation of the update perdurable data uses intelligent control, it is possible to reduce cumbersome repetition judges manually, institute It, can efficient completion data update with no matter object to be modified includes how many Field Count.
It should be understood that the device provided by the above embodiment for updating perdurable data can be real based on computer program Existing, the device is when updating perdurable data, only the example of the division of the above functional modules, in practical application, It can according to need and be completed by different functional modules above-mentioned function distribution, i.e., the internal structure of device is divided into difference Functional module, to complete all or part of the functions described above.In addition, update persistence number provided by the above embodiment According to device and update the embodiment of the method for perdurable data and belong to same design, specific implementation process is detailed in method implementation Example, which is not described herein again.
Fig. 3 is the structural schematic diagram of computer equipment provided in an embodiment of the present invention.The computer equipment 300 can be because of configuration Or performance is different and generate bigger difference, may include one or more central processing units 322 (for example, one or More than one processor) and memory 332, the storage medium of one or more storage application programs 342 or data 344 330 (such as one or more mass memory units).Wherein, memory 332 and storage medium 330 can be of short duration storage Or persistent storage.The program for being stored in storage medium 330 may include one or more modules (diagram does not mark), each Module may include to the series of instructions operation in computer equipment.Further, central processing unit 322 can be set to It is communicated with storage medium 330, the series of instructions operation in storage medium 330 is executed in computer equipment 300.
Computer equipment 300 can also include one or more power supplys 324, one or more are wired or wireless Network interface 350, one or more input/output interfaces 358, one or more keyboards 354, and/or, one or More than one operating system 341, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM Etc..
Computer equipment 300 may include have memory and one perhaps more than one program one of them or More than one program is stored in memory, and be configured to be executed by one or more than one processor it is one or More than one program includes the instruction for carrying out above-mentioned log processing.
Those of ordinary skill in the art will appreciate that realizing that all or part of the steps of above-described embodiment can pass through hardware It completes, relevant hardware can also be instructed to complete by program, the program can store in a kind of computer-readable In storage medium, storage medium mentioned above can be read-only memory, store equipment or CD etc..
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all in spirit of the invention and Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.

Claims (13)

1. a kind of method for updating perdurable data, which is characterized in that the described method includes:
Obtain first instance, wherein the first instance includes whole fields of object to be updated and the value of field to be updated;
Whole fields of the object to be updated and the value of each field are obtained from storage equipment, and is stored in second instance In;
The value of field to be updated described in the second instance is updated to the value of field to be updated described in the first instance;
Updated second instance is persisted in the storage equipment.
2. the method according to claim 1, wherein the step of acquisition first instance, includes:
Obtain the parameter of entity class;
The first instance is generated based on the parameter.
3. the method according to claim 1, wherein described obtain the object to be updated from storage equipment The step of value of whole fields and each field, comprising:
Whether the value for judging the identification field of object to be updated in the first instance is empty;
If it is, process terminates, otherwise obtained from storage equipment the object to be updated whole fields and each word The value of section.
4. according to the method described in claim 3, it is characterized in that, in the judgement first instance object to be updated mark Before whether the value for section of becoming literate is empty step, comprising:
The value of the identification field of object to be updated in the first instance is obtained by Java reflection mechanism.
5. the method according to claim 1, wherein described by field to be updated described in the second instance Value is updated to the step of value of field to be updated described in the first instance, comprising:
Whole fields in the first instance are obtained, and traverse whole fields;
It is not empty field if there is value, then is not empty field using described value as the field to be updated, and will be described The value of field to be updated is assigned in the second instance field identical with the field to be updated.
6. the method according to claim 1, wherein the step for obtaining whole fields in the first instance Suddenly, further includes:
Whether the data for judging the second instance are empty;
If it is, process terminates, whole fields in the first instance are otherwise obtained.
7. a kind of device for updating perdurable data, which is characterized in that described device includes:
First obtains module, for obtaining first instance, wherein the first instance include whole fields of object to be updated with And the value of field to be updated;
Second obtains module, for obtaining the whole fields and each field of the object to be updated from storage equipment Value, and be stored in second instance;
Update module, for by the value of field to be updated described in the second instance be updated to described in the first instance to The value of more newer field;
Persistence module, for updated second instance to be persisted in the storage equipment.
8. device according to claim 7, which is characterized in that described first obtains module, is specifically used for:
Obtain the parameter of entity class;
The first instance is generated based on the parameter.
9. device according to claim 7, which is characterized in that described second obtains module, is specifically used for:
Whether the value for judging the identification field of object to be updated in the first instance is empty;
If it is, process terminates, otherwise obtained from storage equipment the object to be updated whole fields and each word The value of section.
10. device according to claim 9, which is characterized in that described second obtains module, also particularly useful for:
The value of the identification field of object to be updated in the first instance is obtained by Java reflection mechanism.
11. device according to claim 7, which is characterized in that the persistence module is specifically used for:
Whole fields in the first instance are obtained, and traverse whole fields;
It is not empty field if there is value, then is not empty field using described value as the field to be updated, and will be described The value of field to be updated is assigned in the second instance field identical with the field to be updated.
12. device according to claim 7, which is characterized in that the persistence module, also particularly useful for:
Whether the data for judging the second instance are empty;
If it is, process terminates, whole fields in the first instance are otherwise obtained.
13. a kind of computer equipment, which is characterized in that the computer equipment includes processor and memory, the memory In be stored at least one instruction, at least a Duan Chengxu, code set or instruction set, at least one instruction, described at least one Duan Chengxu, the code set or instruction set are loaded by the processor and are executed to realize as described in claim 1 to 6 is any Update the method for perdurable data.
CN201910472372.7A 2019-05-31 2019-05-31 Method and device for updating persistent data Active CN110333883B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910472372.7A CN110333883B (en) 2019-05-31 2019-05-31 Method and device for updating persistent data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910472372.7A CN110333883B (en) 2019-05-31 2019-05-31 Method and device for updating persistent data

Publications (2)

Publication Number Publication Date
CN110333883A true CN110333883A (en) 2019-10-15
CN110333883B CN110333883B (en) 2023-05-16

Family

ID=68140648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910472372.7A Active CN110333883B (en) 2019-05-31 2019-05-31 Method and device for updating persistent data

Country Status (1)

Country Link
CN (1) CN110333883B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115086442A (en) * 2022-08-15 2022-09-20 恒生电子股份有限公司 Data processing method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1776676A (en) * 2004-11-18 2006-05-24 国际商业机器公司 Management of metadata in a storage subsystem, system and computer program
CN101216789A (en) * 2008-01-08 2008-07-09 福建星网锐捷网络有限公司 Data update method, device and system
US20110035405A1 (en) * 2009-06-29 2011-02-10 Raytheon Company Method and system for data class update
CN103345501A (en) * 2013-06-27 2013-10-09 华为技术有限公司 Method and device for updating database
CN103440204A (en) * 2013-08-28 2013-12-11 华为技术有限公司 Method for updating file system and storage device
CN103853671A (en) * 2012-12-07 2014-06-11 北京百度网讯科技有限公司 Data writing control method and device
CN105677250A (en) * 2016-01-04 2016-06-15 北京百度网讯科技有限公司 Method and device for updating object data in object storage system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1776676A (en) * 2004-11-18 2006-05-24 国际商业机器公司 Management of metadata in a storage subsystem, system and computer program
CN101216789A (en) * 2008-01-08 2008-07-09 福建星网锐捷网络有限公司 Data update method, device and system
US20110035405A1 (en) * 2009-06-29 2011-02-10 Raytheon Company Method and system for data class update
CN103853671A (en) * 2012-12-07 2014-06-11 北京百度网讯科技有限公司 Data writing control method and device
CN103345501A (en) * 2013-06-27 2013-10-09 华为技术有限公司 Method and device for updating database
CN103440204A (en) * 2013-08-28 2013-12-11 华为技术有限公司 Method for updating file system and storage device
CN105677250A (en) * 2016-01-04 2016-06-15 北京百度网讯科技有限公司 Method and device for updating object data in object storage system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115086442A (en) * 2022-08-15 2022-09-20 恒生电子股份有限公司 Data processing method and device
CN115086442B (en) * 2022-08-15 2022-12-27 恒生电子股份有限公司 Data processing method and device

Also Published As

Publication number Publication date
CN110333883B (en) 2023-05-16

Similar Documents

Publication Publication Date Title
US5291593A (en) System for persistent and delayed allocation object reference in an object oriented environment
US8209675B2 (en) Method and system for customizing a software application
CN106569783B (en) Method and device for executing task script
CN112394942B (en) Distributed software development compiling method and software development platform based on cloud computing
US20030084063A1 (en) Method, system, and program for performing an impact analysis of program statements in at least one source code file
CN111068328B (en) Game advertisement configuration form generation method, terminal equipment and medium
US10102047B2 (en) In-memory data analytic system that provides an integrated tracking mechanism for explicit memory resources
US9311345B2 (en) Template based database analyzer
CN110134706A (en) SQL statement automatic optimization method, device, computer equipment and storage medium
CN110333883A (en) A kind of method and device updating perdurable data
JPH0565892B2 (en)
CN110377476B (en) Terminal testing method, terminal and readable storage medium
CN113778515B (en) Method and device for determining program package change information
CN114466387B (en) Updating method and device of configuration file of base station, storage medium and electronic device
US8595251B2 (en) Flexible interface module
US20050015264A1 (en) Methods, systems, and a computer-readable medium for defining and evaluating business rules during runtime of a computer software application program
WO2017167543A1 (en) Multiform persistence abstraction
US10268730B2 (en) Focus-driven user interface
CN115941834B (en) Automatic operation method, device, equipment and storage medium of smart phone
US7958330B2 (en) Compiler program, compiler program recording medium, compile method, and program processing system
US9710774B2 (en) Configuration of embedded intelligence
CN116627390B (en) ICD file substitution method and device in aviation software development
CN113296748B (en) Mapping method, system, server and computer readable storage medium of data object and database
US20220334829A1 (en) Custom abap cloud enabler
CN116303570A (en) Optimization method, storage medium and equipment for database operation statement message protocol

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
GR01 Patent grant
GR01 Patent grant