Data persistence method and device, electronic equipment, storage medium and product

By using the target annotation and object relationship mapping framework in the database, the data of dynamic attributes is stored under unstructured fields, which solves the problem of low development efficiency caused by dynamic attribute updates in the database and achieves efficient data persistence.

CN120353776APending Publication Date: 2025-07-22DAWNING NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510347715.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-21
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

In the prior art, the dynamic attribute update of data in the database leads to an increase in the amount of development tasks and low development efficiency.

Method used

By generating target annotations, the data of dynamic attributes is stored under the unstructured data fields of the database, and the data is persisted using the target object relational mapping framework, avoiding creating fields separately based on dynamic attributes.

Benefits of technology

Improve development efficiency, reduce the workload of modifying database fields, and simplify the data operation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120353776A_ABST
    Figure CN120353776A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data persistence method and device, electronic equipment, a storage medium and a product. The method comprises the steps of receiving a data persistence request, wherein the data persistence request comprises at least one piece of original data, at least one dynamic attribute corresponding to at least one piece of target data and a target database identifier; determining an unstructured data field in a target database corresponding to the target data identifier; according to the dynamic attribute and the unstructured data field, generating a target annotation, and adding the target annotation to the original data to obtain target data; and writing the target data into an unstructured data field of the target database through the target annotation and the target object relation mapping framework so as to realize data persistence. According to the scheme, the data with the different dynamic attributes are stored in the same unstructured data field of the database through the serialization technology, different data are distinguished through annotations, the field does not need to be independently created according to the dynamic attributes, and therefore the development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and in particular, to a data persistence method, apparatus, electronic device, storage medium, and product. Background Art

[0002] In modern software development, with the increase in business complexity and data diversity, how to efficiently store, load, and process complex data structures has become an important issue. Data persistence can effectively improve the reliability of data by saving the data in the program to a non-volatile storage medium, such as a database, so that the data can still be accessed after the program is closed or restarted.

[0003] In the related art, multiple fields are added to the database, and the data is classified through the multiple fields to distinguish different data types.

[0004] However, the data in the database is constantly updated, and it is necessary to modify the fields of the database according to the updated data, which increases the development workload and results in low development efficiency. Summary of the Invention

[0005] Embodiments of this application provide a data persistence method, apparatus, electronic device, storage medium, and product to improve development efficiency.

[0006] In a first aspect, an embodiment of this application provides a data persistence method, including: receiving a data persistence request, where the data persistence request includes at least one original data, at least one dynamic attribute corresponding to the at least one original data, and a target database identifier; determining an unstructured data field in a target database corresponding to the target database identifier according to the persistence request; generating a target annotation according to the dynamic attribute and the unstructured data field, adding the target annotation to the original data to obtain target data; and writing the target data into the unstructured data field of the target database through the target annotation and a target object relational mapping framework to implement data persistence.

[0007] Optionally, in the method as described above, generating a target annotation according to the dynamic attribute and the unstructured data field includes: determining a target serialization method corresponding to the unstructured data field; determining a target serialization framework identifier according to the target serialization method, where a target serialization framework corresponding to the target serialization framework identifier can implement the target serialization method; and generating the target annotation according to the dynamic attribute and the target serialization framework identifier.

[0008] Optionally, in the method described above, the target data is written into the unstructured data field of the target database through the target annotation and the target object relationship mapping framework, including: identifying the target annotation through the target object relationship mapping framework to determine the target serialization framework; performing conversion processing on the target data through the target serialization framework to obtain a target data stream; and writing the target data stream into the unstructured data field of the target database through the target object relationship mapping framework.

[0009] Optionally, in the method described above, the conversion processing of the target data through the target serialization framework to obtain a target data stream includes: determining the registration information of the target serialization framework; determining whether the dynamic attribute is included in the registration information; if so, performing conversion processing on the target data through the target serialization framework to obtain the target data stream; if not, registering the dynamic attribute to the target serialization framework to obtain a registered serialization framework, and performing conversion processing on the target data through the registered serialization framework to obtain the target data stream.

[0010] Optionally, in the method described above, the conversion processing of the target data to obtain the target data stream includes: determining a data snapshot of historical data from the memory; obtaining incremental data by comparing the target data with the data snapshot, where the incremental data does not exist in the data snapshot; and performing conversion processing on the incremental data to obtain the target data stream.

[0011] Optionally, in the method described above, the method further includes: receiving a data reading request, where the data reading request includes a reading data identifier; according to the reading data identifier, reading a reading data stream corresponding to the reading data identifier from the target database through the target object relationship mapping framework, and encapsulating the reading data stream into a reading object; identifying the annotation of the reading data stream through the target object relationship mapping framework to determine a reading serialization framework; performing conversion processing on the reading data stream through the reading serialization framework to obtain reading data; and assigning the reading data to an entity class to obtain a target object including the reading data.

[0012] Second aspect, an embodiment of the present application provides a data persistence device, including: a receiving module, configured to receive a data persistence request, where the data persistence request includes at least one piece of original data, at least one dynamic attribute corresponding to the at least one piece of original data, and a target database identifier; a determining module, configured to determine an unstructured data field in a target database corresponding to the target database identifier according to the persistence request; a generating module, configured to generate a target annotation according to the dynamic attribute and the unstructured data field, and add the target annotation to the original data to obtain target data; a writing module, configured to write the target data into the unstructured data field of the target database through the target annotation and a target object-relational mapping framework to implement data persistence.

[0013] Optionally, for the device as described above, the generating module is specifically configured to determine a target serialization method corresponding to the unstructured data field; the generating module is further specifically configured to determine a target serialization framework identifier according to the target serialization method, and a target serialization framework corresponding to the target serialization framework identifier can implement the target serialization method; the generating module is further specifically configured to generate the target annotation according to the dynamic attribute and the target serialization framework identifier.

[0014] Optionally, for the device as described above, the device further includes: a processing module, configured to perform recognition processing on the target annotation through a target object-relational mapping framework to determine the target serialization framework; the processing module is further configured to perform conversion processing on the target data through the target serialization framework to obtain a target data stream; the processing module is further configured to write the target data stream into the unstructured data field of the target database through the target object-relational mapping framework.

[0015] Optionally, for the device as described above, the processing module is specifically configured to determine registration information of the target serialization framework; the processing module is further specifically configured to determine whether the registration information includes the dynamic attribute; the processing module is further specifically configured to, if so, perform conversion processing on the target data through the target serialization framework to obtain the target data stream; the processing module is further specifically configured to, if not, register the dynamic attribute to the target serialization framework to obtain a registered serialization framework, and perform conversion processing on the target data through the registered serialization framework to obtain the target data stream.

[0016] Optionally, for the device as described above, the device further includes: a conversion module, configured to determine a data snapshot of historical data from a memory; the conversion module is further configured to obtain incremental data by comparing the target data with the data snapshot, where the incremental data does not exist in the data snapshot; the conversion module is further configured to perform conversion processing on the incremental data to obtain the target data stream.

[0017] Optionally, for the device as described above, the device further includes: a reading module, configured to receive a data reading request, where the data reading request includes a reading data identifier; the reading module is further configured to, according to the reading data identifier, read a reading data stream corresponding to the reading data identifier from the target database through the target object-relational mapping framework, and encapsulate the reading data stream into a reading object; the reading module is further configured to, through the target object-relational mapping framework, perform recognition processing on the annotation of the reading data stream to determine a reading serialization framework; the reading module is further configured to perform conversion processing on the reading data stream through the reading serialization framework to obtain reading data; the reading module is further configured to assign the reading data to an entity class to obtain a target object including the reading data.

[0018] In a third aspect, an embodiment of the present application provides a data persistence device, including: a memory, a processor;

[0019] The memory stores computer-executable instructions;

[0020] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the first aspect and / or various possible implementation manners of the first aspect as described above.

[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the first aspect and / or various possible implementation manners of the first aspect as described above.

[0022] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the first aspect and / or various possible implementation manners of the first aspect as described above.

[0023] The data persistence method, apparatus, electronic device, storage medium, and product provided by the embodiments of the present application, the method includes: receiving a data persistence request, the data persistence request including at least one original data, at least one dynamic attribute corresponding to the at least one target data, and a target database identifier; determining an unstructured data field in the target database corresponding to the target data identifier according to the persistence request; generating a target annotation according to the dynamic attribute and the unstructured data field, adding the target annotation to the original data to obtain target data; writing the target data into the unstructured data field of the target database through the target annotation and a target object relational mapping framework to implement data persistence. The above solution stores data with different dynamic attributes in the same unstructured data field of the database through serialization technology, and differentiates different data through annotations, without creating fields separately according to dynamic attributes, thereby improving development efficiency. Description of the Drawings

[0024] The drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.

[0025] Figure 1 Schematic diagram of an application scenario of a data persistence method provided by an embodiment of the present application;

[0026] Figure 2 Schematic diagram of a process of a data persistence method provided by an embodiment of the present application;

[0027] Figure 3 Schematic diagram of a process of a data persistence method provided by an embodiment of the present application;

[0028] Figure 4 Schematic diagram of generating a target annotation provided by an embodiment of the present application;

[0029] Figure 5 Schematic diagram of conversion processing provided by an embodiment of the present application;

[0030] Figure 6 Schematic diagram of data reading and writing provided by an embodiment of the present application;

[0031] Figure 7 Schematic diagram of the structure of a data persistence apparatus provided by an embodiment of the present application;

[0032] Figure 8 Schematic diagram of the structure of a data persistence apparatus provided by an embodiment of the present application;

[0033] Figure 9 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application.

[0034] Through the above-mentioned accompanying drawings, specific embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These drawings and written descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed Embodiments

[0035] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0036] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or fully authorized by all parties. Moreover, the processing of relevant data, such as collection, use, processing, transmission, provision, disclosure, and application, complies with relevant laws, regulations, and standards of relevant countries and regions, takes necessary confidentiality measures, does not violate public order and good customs, and provides corresponding operation entrances for users to choose to authorize or refuse.

[0037] It should be noted that the data persistence method, device, electronic device, storage medium, and product of the present application can be used in the field of data processing, and can also be used in any field other than data processing. The application field of the data persistence method, device, electronic device, storage medium, and product of the present application is not limited.

[0038] Figure 1 FIG. is a schematic diagram of an application scenario of a data persistence method provided by an embodiment of the present application. An example is given in combination with the illustrated scenario: Data that needs to be used repeatedly is stored in a database, and the data can be read from the database at any time according to the usage needs.

[0039] Optionally, each data has a corresponding dynamic attribute. The dynamic data can be a data type, such as Boolean, Byte, Short, Integer, Double, Float, Long, String, List, or Object, etc. The dynamic attribute is related to the application scenario or usage method of the data, so it needs to be distinguished.

[0040] In the related art, by adding fields corresponding to dynamic attributes in the database, the dynamic attributes of each piece of data in the database are distinguished. The core idea of this method is to directly map the dynamic attributes of the data to the columns of the database, so as to realize the storage and management of these dynamic attributes.

[0041] However, this method has the problem of poor scalability, especially for dynamic attributes that may change during runtime. For example, when persisting a batch of new data, if the dynamic attributes of the new data are different from those of the existing data in the database, the fields in the database need to be modified to distinguish the new data. This will increase the development workload and lead to low development efficiency.

[0042] The data persistence method provided by this application aims to solve the above technical problems in the prior art.

[0043] The following uses specific embodiments to elaborate in detail on the technical solution of this application and how the technical solution of this application solves the above technical problems. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below in conjunction with the drawings.

[0044] Figure 2 FIG. is a schematic flowchart of a data persistence method provided for an embodiment of this application. The method includes the following steps:

[0045] S201. Receive a data persistence request, where the data persistence request includes at least one piece of original data, at least one dynamic attribute corresponding to the at least one piece of original data, and a target database identifier.

[0046] Exemplarily, the target database identifier is used to identify the target database, and the target database is the database specified by the data persistence request. The original data is the data that needs to be stored in the target database as specified. The dynamic attribute is used to represent the characteristics of the original data.

[0047] Optionally, each piece of original data corresponds to one dynamic attribute. The dynamic attribute plays a guiding role in the use process of the original data.

[0048] S202. According to the persistence request, determine the unstructured data fields in the target database corresponding to the target database identifier.

[0049] Among them, an unstructured data field refers to a specific field in a database or data storage system used to store unstructured data. These fields can hold data without a fixed format or organization. Different from traditional structured fields (such as integer type, character type, etc.), unstructured data fields do not follow a fixed pattern or predefined structure. For example, unstructured data fields can be Blob, JSON, or Text, etc.

[0050] Optionally, the database identifier is the unique identifier of the database.

[0051] Optionally, determine the uniquely corresponding target database according to the target database identifier, and identify the unstructured data fields from the target database.

[0052] S203. Generate a target annotation based on the dynamic attributes and unstructured data fields, and add the target annotation to the original data to obtain the target data.

[0053] Exemplarily, the target annotation is used to identify the dynamic attributes of the original data, and the dynamic attributes of the original data can be accurately determined through the target annotation.

[0054] Exemplarily, the type of the unstructured data field determines the storage method that the target annotation needs to describe. For example, if a JSON field is used to store dynamic attributes, the target annotation needs to specify that the data format of the field is JSON. For Blob fields or other complex data fields, the target annotation can specify the serialization and deserialization methods (such as Kryo, JSON, etc.) to correctly process the data in the field. The unstructured data field itself lacks clear semantic information, and the target annotation can supplement this information. For example, the annotation can explain through parameters what specific attributes are stored in a certain JSON field.

[0055] Combined with a scenario example, adding the target annotation as additional information to the original data to obtain the target data can improve the readability of the target data, and the corresponding dynamic attributes can be quickly determined through the target data.

[0056] S204. Write the target data into the unstructured data field of the target database through the target annotation and the target object-relational mapping framework to achieve data persistence.

[0057] Exemplarily, the target object-relational mapping framework greatly simplifies the data operation process by mapping the target data to the database structure, reduces manual operations, and can improve the efficiency of data writing.

[0058] Combined with a scenario example, writing the target data uniformly under the unstructured data field does not require modifying the fields of the target database according to the dynamic attributes, thus reducing the development workload.

[0059] The data persistence method provided by the embodiment of the present application receives a data persistence request, where the data persistence request includes at least one piece of original data, at least one dynamic attribute corresponding to at least one piece of target data, and a target database identifier; according to the persistence request, determine the unstructured data field in the target database corresponding to the target data identifier; generate a target annotation based on the dynamic attribute and the unstructured data field, add the target annotation to the original data to obtain the target data; write the target data into the unstructured data field of the target database through the target annotation and the target object relational mapping framework to achieve data persistence. In the above solution, different dynamic attribute data is stored under the same unstructured data field in the database through serialization technology, and different data is distinguished through annotations, without the need to separately create fields according to dynamic attributes, thereby improving development efficiency.

[0060] Based on any one of the above embodiments, below, in combination with Figure 3 , the detailed process of data persistence will be described.

[0061] Figure 3 It is a schematic flowchart of a data persistence method provided by an embodiment of the present application. As Figure 3 shown, the method includes:

[0062] S301. Receive a data persistence request, where the data persistence request includes at least one piece of original data, at least one dynamic attribute corresponding to at least one piece of original data, and a target database identifier.

[0063] It should be noted that the execution process of S301 refers to S201, which will not be elaborated here.

[0064] S302. According to the persistence request, determine the unstructured data field in the target database corresponding to the target database identifier.

[0065] It should be noted that the execution process of S302 refers to S202, which will not be elaborated here.

[0066] S303. Determine the target serialization method corresponding to the unstructured data field.

[0067] Exemplarily, serialization is to convert different types of data into a unified byte stream format, and the unified format can be directly stored in the unstructured data field of the database without the need to separately create fields for each dynamic attribute.

[0068] Optionally, determine the target serialization method according to the data complexity. For example, for complex objects or nested structures, a high-performance serialization method is selected.

[0069] S304. Determine the target serialization framework identifier according to the target serialization method. The target serialization framework corresponding to the target serialization framework identifier can implement the target serialization method.

[0070] Among them, a serialization framework is a software tool or library used to convert the state of an object into a format that can be stored or transmitted (referred to as serialization) and restore it to the original object when needed (referred to as deserialization). The core function of the serialization framework is to simplify the process of object persistence and communication, so that developers do not need to manually handle complex serialization logic.

[0071] Illustrated with a scenario example, for example, according to the high-performance serialization method, determine that the target serialization framework is Kryo. For example, according to the binary serialization method, determine that the target serialization framework is Kryo.

[0072] S305. Generate a target annotation according to the dynamic attribute and the target serialization framework identifier.

[0073] Next, Figure 4 describe the generation of the target annotation.

[0074] Figure 4 FIG. is a schematic diagram of generating a target annotation provided by an embodiment of the present application. As Figure 4 shown, extract the dynamic attributes of the original data from the original data, and the dynamic attributes reflect the characteristics of the original data. Extract the unstructured data fields from the target database, and select the target serialization framework that matches the unstructured data fields. Generate the target annotation corresponding to the dynamic attribute through the target serialization framework.

[0075] Optionally, determine the format of the target annotation according to the target object-relational mapping framework. For example, the Hibernate object-relational mapping framework can recognize the @Type format, and the target annotation modified by @Type can improve readability.

[0076] Illustrated with a scenario example, the target annotation is used to provide a note for the target data to guide the object-relational mapping framework to complete operations such as serialization, deserialization, and persistence of the data. By generating the target annotation with multiple types of information, the comprehensiveness of the target annotation can be improved.

[0077] Based on the above implementation, the target annotation clearly describes the dynamic attributes and serialization methods, simplifies the code logic, and reduces the maintenance cost.

[0078] S306. Perform an identification process on the target annotation through the target object-relational mapping framework to determine the target serialization framework.

[0079] Exemplarily, the target object relationship mapping framework identifies the target serialization framework identifier in the target annotation, and determines the corresponding target serialization framework according to the target serialization framework identifier.

[0080] Illustrated with a scenario example, the format of the information in the target annotation is a format recognizable by the target object relationship mapping framework. Through the target annotation, the target object relationship mapping framework can automatically identify and determine the target serialization framework, thereby reducing manual operations and improving the efficiency of data persistence.

[0081] S307. Perform transformation processing on the target data through the target serialization framework to obtain a target data stream.

[0082] Optionally, perform transformation processing on the target data through the transformation function of the target object relationship mapping framework and the target serialization framework.

[0083] Exemplarily, taking the transformation function nullSafeSet of the Hibernate object relationship mapping framework and the Kryo serialization framework as an example, Kryo is mainly used to serialize data into a data stream for storage or transmission. When these serialized data streams need to be saved to a database, unstructured data fields may be involved. nullSafeSet can ensure proper handling of null values in the data stream, avoiding data integrity issues caused by null.

[0084] Based on the above embodiments, targeted transformation of the target data can adapt to the actual application scenario of the target data and improve the accuracy of the transformation.

[0085] A feasible implementation method can perform transformation processing through the following steps: determine the registration information of the target serialization framework; determine whether the registration information includes dynamic attributes; if so, perform transformation processing on the target data through the target serialization framework to obtain a target data stream; if not, register the dynamic attributes to the target serialization framework to obtain a registered serialization framework, and perform transformation processing on the target data through the registered serialization framework to obtain a target data stream.

[0086] Illustrated with a scenario example, if the registration information does not include dynamic attributes, the target serialization framework cannot recognize the unregistered dynamic attributes. At this time, if transformation processing is directly performed, the target serialization framework may generate an exception or directly ignore these dynamic attributes, resulting in inaccurate data persistence.

[0087] Next, Figure 5 the transformation processing will be described.

[0088] Figure 5 is a schematic diagram of the transformation processing provided by the embodiments of the present application. As Figure 5As shown, before performing the conversion process, it is determined whether the registration information includes dynamic attributes. If so, it means that dynamic attributes were registered during the persistence of historical data, and then the conversion process can be performed through the target serialization framework. If not, it means that the historical data does not include the dynamic attributes in the current data persistence request. In the related art, the database fields need to be modified, while in this application, only the dynamic attributes need to be registered in the target serialization framework without changing the database.

[0089] Optionally, the registered serialization framework is used for data conversion of subsequent other requests, and the already registered dynamic attributes do not need to be registered again, thus improving the development efficiency.

[0090] In this feasible implementation, through the verification process, it can be ensured that the dynamic attributes are registered in the serialization framework, thereby improving the reliability of the conversion.

[0091] A feasible implementation can perform the conversion process through the following method: determine the data snapshot of the historical data from the memory; obtain the incremental data by comparing the target data with the data snapshot, where the incremental data does not exist in the data snapshot; perform the conversion process on the incremental data to obtain the target data stream.

[0092] Exemplarily, the historical data is the data that has been persisted, the historical data is the data state stored at a certain time point, and the data snapshot is a copy of the historical data.

[0093] Exemplarily, by comparing the target data with the historical snapshot, it can be determined which data in the target data has been persisted and which data has not been persisted. The data that has not been persisted is the incremental data. Only persisting the incremental data can avoid duplication and reduce the workload.

[0094] Optionally, for simple key-value pair data, the comparison process can be performed by comparing whether the key exists and whether the values are the same. For complex objects or nested structures, the comparison process can be performed by recursively comparing each field or sub-object.

[0095] In this feasible implementation, by performing the conversion process on the incremental data, redundant operations can be reduced, and the repeated processing of the entire target data can be avoided, thereby improving the efficiency of data persistence. Only storing the incremental data can reduce the requirements for storage space and network bandwidth.

[0096] S308. Write the target data stream into the unstructured data field of the target database through the target object-relational mapping framework.

[0097] Optionally, determine the target object-relational mapping framework according to project requirements, database type, or language ecosystem.

[0098] Exemplarily, taking project requirements as an example, if a project involves complex queries, association relationships, or multi-table operations, a powerful object-relational mapping framework (such as Hibernate) can be selected. If a project needs to flexibly switch databases or support multiple database types, an object-relational mapping that supports a wide range should be chosen. If a project is applied in a high-performance scenario, a lightweight object-relational mapping framework (such as MyBatis) can be selected to reduce the overhead of the framework itself. Taking the database type as an example, databases include relational databases and non-relational databases, and the target object-relational mapping framework supported by the database type should be selected. Taking the language ecosystem as an example, the object-relational mapping framework supported by the development language should be selected.

[0099] Based on the above embodiments, by writing unstructured data fields, the problem of database field adjustment caused by adding dynamic attributes of new data in the prior art can be avoided, thereby improving development efficiency.

[0100] A feasible implementation manner is that the data persistence method further includes: receiving a data reading request, where the data reading request includes a reading data identifier; according to the reading data identifier, through the target object-relational mapping framework, reading the reading data stream corresponding to the reading data identifier from the target database, and encapsulating the reading data stream into a reading object; through the target object-relational mapping framework, identifying and processing the annotations of the reading data stream to determine the reading serialization framework; performing conversion processing on the reading data stream through the reading serialization framework to obtain reading data; and assigning the reading data to an entity class to obtain a target object including the reading data.

[0101] Next, Figure 6 data reading and writing will be described.

[0102] Figure 6 is a schematic diagram of data reading and writing provided by the embodiments of the present application. As Figure 6 shown, the target object-relational mapping framework performs conversion processing on the original data according to the data persistence request and writes it into the target database. The target object-relational mapping framework reads the reading data from the target database according to the data reading request. During the data reading and writing process, the database fields do not need to be modified, thereby improving development efficiency.

[0103] Optionally, the reading data stream is encapsulated into an intermediate object, which is only used for data transmission and does not involve specific business logic. The advantage of encapsulation is that it can simplify the subsequent processing flow and make the code clearer and more modular.

[0104] Optionally, the reading serialization framework is determined through the information in the annotation, and the reading data stream is converted into reading data through the deserialization method in the reading serialization framework.

[0105] Optionally, the read data is filled into the attributes of the entity class to obtain a target object that returns the complete data. The entity class is a class that represents a business object in a program and usually contains multiple fields to store data.

[0106] In this feasible implementation, after the assignment is completed, the developer can directly access the data through the attributes or methods of the entity class, without manually parsing the database query results, which can simplify the workload and improve the development efficiency.

[0107] Figure 7 The following is a schematic structural diagram of a data persistence device provided by an embodiment of the present application. As Figure 7 shown, the data persistence device 70 may include: a receiving module 71, a determining module 72, a generating module 73, and a writing module 74, where

[0108] The receiving module 71 is configured to receive a data persistence request, where the data persistence request includes at least one piece of original data, at least one dynamic attribute corresponding to the at least one piece of original data, and a target database identifier.

[0109] The determining module 72 is configured to determine the unstructured data fields in the target database corresponding to the target database identifier according to the persistence request.

[0110] The generating module 73 is configured to generate a target annotation according to the dynamic attribute and the unstructured data field, and add the target annotation to the original data to obtain target data.

[0111] The writing module 74 is configured to write the target data into the unstructured data field of the target database through the target annotation and the target object relational mapping framework to implement data persistence.

[0112] Optionally, the receiving module 71 may execute Figure 2 S201 in the embodiment.

[0113] Optionally, the determining module 72 may execute Figure 2 S202 in the embodiment.

[0114] Optionally, the generating module 73 may execute Figure 2 S203 in the embodiment.

[0115] Optionally, the writing module 74 may execute Figure 2 S204 in the embodiment.

[0116] It should be noted that the data persistence device shown in the embodiment of the present application may execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, and will not be elaborated here.

[0117] In a possible implementation, the generation module 73 is specifically configured to:

[0118] Determine the target serialization method corresponding to the unstructured data field;

[0119] According to the target serialization method, determine the target serialization framework identifier, and the target serialization framework corresponding to the target serialization framework identifier can implement the target serialization method;

[0120] Generate a target annotation according to the dynamic attribute and the target serialization framework identifier.

[0121] Figure 8 This is a schematic structural diagram of a data persistence device provided by an embodiment of the present application. Based on the Figure 7 embodiment shown, as Figure 8 shown, the data persistence device 80 further includes: a processing module 75, a conversion module 76, and a reading module 77, where

[0122] The processing module 75 is configured to:

[0123] Identify and process the target annotation through the target object-relational mapping framework to determine the target serialization framework;

[0124] Convert the target data through the target serialization framework to obtain a target data stream;

[0125] Write the target data stream into the unstructured data field of the target database through the target object-relational mapping framework.

[0126] In a possible implementation, the processing module 75 is specifically configured to:

[0127] Determine the registration information of the target serialization framework;

[0128] Determine whether the registration information includes dynamic attributes;

[0129] If so, convert the target data through the target serialization framework to obtain a target data stream;

[0130] If not, register the dynamic attribute to the target serialization framework to obtain a registered serialization framework, and convert the target data through the registered serialization framework to obtain a target data stream.

[0131] The conversion module 76 is configured to:

[0132] Determine the data snapshot of the historical data from the memory;

[0133] Obtain incremental data by comparing the target data with the data snapshot, and the incremental data does not exist in the data snapshot;

[0134] Perform conversion processing on the incremental data to obtain the target data stream.

[0135] A reading module 77, configured to:

[0136] Receive a data reading request, where the data reading request includes a reading data identifier;

[0137] According to the reading data identifier, through the target object relational mapping framework, read the reading data stream corresponding to the reading data identifier from the target database, and encapsulate the reading data stream into a reading object;

[0138] Through the target object relational mapping framework, perform recognition processing on the annotations of the reading data stream to determine the reading serialization framework;

[0139] Perform conversion processing on the reading data stream through the reading serialization framework to obtain the reading data;

[0140] Assign the reading data to the entity class to obtain a target object including the reading data.

[0141] Figure 9 The figure is a schematic structural diagram of an electronic device provided in an embodiment of the present application. As Figure 9 shown, the electronic device includes:

[0142] A processor 291. The electronic device further includes a memory 292; it may also include a communication interface 293 and a bus 294. Among them, the processor 291, the memory 292, and the communication interface 293 can complete mutual communication through the bus 294. The communication interface 293 can be used for information transmission. The processor 291 can call the logical instructions in the memory 292 to execute the method of the above embodiment.

[0143] In addition, when the logical instructions in the above-mentioned memory 292 are implemented in the form of a software functional unit and sold or used as an independent product, they can be stored in a computer-readable storage medium.

[0144] The memory 292, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as the program instructions / modules corresponding to the method in the embodiment of the present application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, implements the method in the above method embodiment.

[0145] The memory 292 may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.

[0146] An embodiment of the present application provides a non-transitory computer-readable storage medium storing computer-executable instructions, which are used to implement the method in the foregoing embodiment when executed by a processor.

[0147] An embodiment of the present application provides a computer program product including a computer program, which implements the method in the foregoing embodiment when executed by a processor.

[0148] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0149] Furthermore, it should be noted that although the steps in the flowchart are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limitation, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

[0150] It should be understood that the above device embodiments are illustrative, and the devices of the present application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0151] In addition, unless otherwise specified, in each embodiment of the present application, each functional unit / module can be integrated into one unit / module, or each unit / module can exist physically alone, or two or more units / modules can be integrated together. The above integrated unit / module can be implemented in the form of hardware or in the form of a software program module.

[0152] When the integrated unit / module is implemented in the form of hardware, the hardware can be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. The processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. The storage unit can be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc.

[0153] When the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a memory and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in each embodiment of the present application. The aforementioned memory includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs, etc., all of which can store program codes.

[0154] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as falling within the scope described in this specification.

[0155] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and the embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.

[0156] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.

Claims

1. A data persistence method, characterized in that, Including: Receiving a data persistence request, where the data persistence request includes at least one piece of original data, at least one dynamic attribute corresponding to the at least one piece of original data, and a target database identifier; Determining, according to the persistence request, the unstructured data field in the target database corresponding to the target database identifier; Generating a target annotation according to the dynamic attribute and the unstructured data field, and adding the target annotation to the original data to obtain target data; Writing the target data into the unstructured data field of the target database through the target annotation and the target object-relational mapping framework to achieve data persistence.

2. The method according to claim 1, wherein Generating a target annotation according to the dynamic attribute and the unstructured data field, including: Determining the target serialization method corresponding to the unstructured data field; Determining, according to the target serialization method, a target serialization framework identifier, and the target serialization framework corresponding to the target serialization framework identifier can implement the target serialization method; Generating the target annotation according to the dynamic attribute and the target serialization framework identifier.

3. The method according to claim 2, wherein Writing the target data into the unstructured data field of the target database through the target annotation and the target object-relational mapping framework, including: Performing recognition processing on the target annotation through the target object-relational mapping framework to determine the target serialization framework; Performing conversion processing on the target data through the target serialization framework to obtain a target data stream; Writing the target data stream into the unstructured data field of the target database through the target object-relational mapping framework.

4. The method according to claim 3, characterized in that, Performing conversion processing on the target data through the target serialization framework to obtain a target data stream, including: Determining the registration information of the target serialization framework; Determining whether the dynamic attribute is included in the registration information; If so, performing conversion processing on the target data through the target serialization framework to obtain the target data stream; If not, registering the dynamic attribute to the target serialization framework to obtain a registered serialization framework, and performing conversion processing on the target data through the registered serialization framework to obtain the target data stream.

5. The method according to claim 3 or 4, characterized in that, Performing conversion processing on the target data to obtain the target data stream, including: Determining a data snapshot of historical data from memory; Obtaining incremental data by comparing the target data and the data snapshot, where the incremental data does not exist in the data snapshot; Performing conversion processing on the incremental data to obtain the target data stream.

6. The method according to any one of claims 1-5, characterized in that, The method further includes: Receiving a data reading request, where the data reading request includes a reading data identifier; According to the reading data identifier, reading, through the target object-relational mapping framework, the reading data stream corresponding to the reading data identifier from the target database, and encapsulating the reading data stream into a reading object; Performing recognition processing on the annotation of the reading data stream through the target object-relational mapping framework to determine a reading serialization framework; Performing conversion processing on the reading data stream through the reading serialization framework to obtain reading data; Assign the read data to an entity class to obtain a target object including the read data.

7. A data persistence device, characterized in that, Comprising: A receiving module for receiving a data persistence request, the data persistence request including at least one raw data, at least one dynamic attribute corresponding to the at least one raw data, and a target database identifier; A determining module for determining an unstructured data field in a target database corresponding to the target database identifier according to the persistence request; A generating module for generating a target annotation according to the dynamic attribute and the unstructured data field, and adding the target annotation to the raw data to obtain target data; A writing module for writing the target data under the unstructured data field of the target database through the target annotation and a target object relational mapping framework to achieve data persistence.

8. An electronic device, characterized in that, Comprising: A processor and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1-6.

10. A computer program product, characterized in that, Comprising a computer program, which when executed by a processor implements the method according to any one of claims 1-6.