Atomic data storage method and device, equipment and storage medium

By introducing a type processor in the database storage process, automatically converting atomic data types, the problem of difficulty in storage conversion of atomic data types in the prior art is solved, and development efficiency and data consistency are improved.

CN120144648APending Publication Date: 2025-06-13GUANGZHOU BAOLUN ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510110441.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

In the prior art, atomic data types have difficulty in converting them in database storage, which leads to developers need to manually convert them, which increases development complexity and error risks.

Method used

By introducing a type processor in the database storage process, it automatically determines whether the data to be stored is an atomic data type and converts it into a preset data type supported by the database to realize automated atomic data type conversion.

Benefits of technology

It reduces the need for developers to manually write converted code, improves development efficiency, ensures data consistency and integrity, and avoids the problems of human error and type mismatch.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144648A_ABST
    Figure CN120144648A_ABST
Patent Text Reader

Abstract

According to the atomic data storage method and device, the equipment and the storage medium provided by the invention, whether the data type of the to-be-stored data is the atomic data type or not is judged by responding to the database storage instruction; if the to-be-stored data is an atomic data type, converting the data type of the to-be-stored data into a preset data type through a type processor to obtain target stored data; and storing the target storage data in a database. According to the method, the value of the atomic data type is automatically extracted and converted into the proper common data type, so that the problems of human errors and type mismatching are avoided, the consistency and integrity of the data are ensured, the requirement of a developer for manually writing a conversion code is reduced, and the development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a method, apparatus, device, and storage medium for storing atomic data. Background Art

[0002] In the process of data processing and database storage, with the development of multithreaded programming and concurrent computing, atomic data types (such as AtomicReference, AtomicInteger, AtomicLong, etc.) have been widely used in programming languages such as Java. These atomic data types are designed to ensure that data operations are atomic in a multithreaded environment, avoiding data conflicts and inconsistencies. Atomic data types are usually used to represent thread-safe objects, which can be modified without locking, and the modification operations are visible to other threads.

[0003] However, in database storage, there are certain difficulties in the storage and processing of atomic data types. Traditional relational databases (such as MySQL, PostgreSQL, etc.) do not natively support atomic data types, which leads to the need for conversion when storing such data in the database. For this reason, developers usually need to manually convert these data from atomic types to types supported by the database, such as BigDecimal, Integer, Long, etc. This not only increases the complexity of development but also easily leads to errors, affecting the stability and performance of the system.

[0004] In summary, the problems existing in the prior art need to be solved urgently. Summary of the Invention

[0005] The present invention provides a method, apparatus, device, and storage medium for storing atomic data, which is used to solve the defects in the prior art, and realizes automatic conversion of atomic data types, reducing the need for developers to manually write conversion code and improving development efficiency.

[0006] The present invention provides a method for storing atomic data, including:

[0007] In response to a database storage instruction, determining whether the data type of the data to be stored is an atomic data type;

[0008] If the data to be stored is an atomic data type, converting the data type of the data to be stored into a preset data type through a type processor to obtain target stored data;

[0009] Storing the target stored data in the database.

[0010] According to a storage method of atomic data provided by the present invention, the step of, if the data to be stored is of atomic data type, converting the data type of the data to be stored into a preset data type through a type processor to obtain target stored data specifically includes:

[0011] If the data to be stored is of atomic data type, extract the value of the data to be stored through a type processor to obtain the actual data value;

[0012] Obtain the target stored data according to the actual data value and the data type of the actual data value.

[0013] According to a storage method of atomic data provided by the present invention, the type processor is obtained through the following steps:

[0014] Create a type processor, which is used to convert the data type of the data to be processed into a preset data type;

[0015] Register the type processor into the configuration file of MyBatis;

[0016] Create an entity class and a Mapper interface in MyBatis. The entity class is used to map the database table, and the Mapper interface is used to execute database operations.

[0017] According to a storage method of atomic data provided by the present invention, after the step of creating an entity class and a Mapper interface in MyBatis, the method further includes:

[0018] Create a test object, and the data type of the test object is of atomic data type;

[0019] Perform an insert operation on the test object;

[0020] When the data in the test object is successfully inserted into the database, the type processor is successfully registered.

[0021] According to a storage method of atomic data provided by the present invention, the atomic data type is AtomicReference <t>Type;

[0022] where T is a basic data type.

[0023] According to a method for storing atomic data provided by the present invention, the basic data types include: BigDecimal, Integer, Long.

[0024] According to a method for storing atomic data provided by the present invention, the preset data types include BigDecimal, Integer, Double, Boolean.

[0025] The present invention also provides a storage device for atomic data, including:

[0026] A data judgment module, configured to judge whether the data type of the data to be stored is an atomic data type in response to a database storage instruction;

[0027] A data judgment module, configured to, if the data to be stored is an atomic data type, convert the data type of the data to be stored into a preset data type through a type processor to obtain target stored data;

[0028] A data storage module, configured to store the target stored data in a database.

[0029] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the program, the method for storing atomic data as described in any one of the above is implemented.

[0030] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for storing atomic data as described in any one of the above is implemented.

[0031] The present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method for storing atomic data as described in any one of the above is implemented.

[0032] The storage method, device, equipment and storage medium for atomic data provided by the present invention determine whether the data type of the data to be stored is an atomic data type in response to a database storage instruction; if the data to be stored is an atomic data type, the type processor is used to convert the data type of the data to be stored into a preset data type to obtain the target stored data; and the target stored data is stored in the database. The present invention automatically extracts and converts the values of atomic data types into appropriate ordinary data types, avoiding human errors and type mismatch problems, ensuring data consistency and integrity, and reducing the need for developers to manually write conversion code, thereby improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0034] Figure 1 is a flowchart of the storage method for atomic data provided by the present invention;

[0035] Figure 2 is a structural diagram of the storage device for atomic data provided by the present invention;

[0036] Figure 3 is a structural diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0037] To make the objectives, technical solutions and advantages of the present invention clearer, the following will clearly and completely describe the technical solutions in the present invention with reference to the drawings in the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments in the present invention belong to the scope of protection of the present invention.

[0038] To solve the problems in the prior art, the present invention proposes a storage method for atomic data to achieve automated atomic data type conversion, reducing the need for developers to manually write conversion code and improving development efficiency. The following describes the storage method for atomic data, as Figure 1 shown, including but not limited to the following steps:

[0039] Step 110: In response to a database storage instruction, determine whether the data type of the data to be stored is an atomic data type.

[0040] In this step, the system first needs to respond to the storage instruction from the database. This storage instruction is usually triggered by the developer during database operations, such as when performing insert or update operations. After receiving this storage instruction, the system first needs to judge the data type of the data to be stored. The purpose of the judgment is to determine whether the data is an atomic data type, such as AtomicReference <t>, AtomicInteger, AtomicLong and other types.

[0041] During the judgment process, the system will check the object type of the data to be stored, which can be completed through reflection mechanism or type comparison. If the data to be stored is an atomic data type (such as AtomicReference <t>) If so, go to step 120; if the data is not of atomic data type, skip the subsequent conversion process and directly store the data in the database.

[0042] The key to this step is to accurately identify whether the data to be stored is of atomic type. Atomic data types are usually used in scenarios of concurrent operations. The system determines whether it meets the atomicity requirements through built-in mechanisms and makes corresponding processing.

[0043] Step 120: If the data to be stored is of atomic data type, convert the data type of the data to be stored into a preset data type through a type handler to obtain the target data to be stored.

[0044] Once the system determines that the data to be stored is of atomic data type, it will enter this step. At this time, the system will use a custom type handler (TypeHandler) to convert the atomic data type into a preset data type supported by the database, such as BigDecimal, Integer, Long, etc. The type handler is the core component for implementing data type conversion, responsible for extracting the actual value from the atomic data type and converting it into a type suitable for database storage.

[0045] Specifically, the type handler performs the following operations:

[0046] If the data to be stored is of atomic data type, the type handler will extract the actual value of the data. For example, for AtomicReference <integer>For data of this type, the type handler will obtain the Integer value wrapped in the AtomicReference.

[0047] Based on the actual value of the data to be stored, the type handler converts it into a preset data type. For example, it converts the value in AtomicInteger to the Integer type, or the value in AtomicLong to the Long type.

[0048] The type handler returns the converted data (i.e., the target data to be stored) for use in subsequent storage steps.

[0049] The implementation of this step can be completed by registering a custom type handler in frameworks such as MyBatis. The type handler dynamically converts the atomic data type into a type that the database can accept according to the data type of the database field. In this way, developers do not need to perform data type conversion manually, simplifying the data storage process and improving development efficiency.

[0050] Step 130: Store the target data to be stored into the database.

[0051] After completing the data type conversion and when the final target data to be stored is ready, the system will store it into the database. At this time, the database operations are usually automatically executed by an ORM framework (such as MyBatis, Hibernate). The system stores the converted data into the corresponding database fields to complete database insert, update and other operations.

[0052] Specifically, the system will execute SQL statements through the database connection, for example:

[0053] Insert operation: If it is to insert new data, the system will insert the converted data into the database table.

[0054] Update operation: If it is to update existing data, the system will update the target data to the corresponding database record according to the primary key or other identifiers of the data.

[0055] In this way, the storage process of the atomic data type can be effectively managed and ensure that the data can be stored in the database in an appropriate format.

[0056] The storage method for atomic data provided by the present invention determines whether the data type of the data to be stored is an atomic data type in response to a database storage instruction; if the data to be stored is an atomic data type, the type processor converts the data type of the data to be stored into a preset data type to obtain the target stored data; and stores the target stored data in the database. The present invention automatically extracts and converts the values of atomic data types into appropriate ordinary data types, avoiding human errors and type mismatch problems, ensuring data consistency and integrity, and reducing the need for developers to manually write conversion code, thereby improving development efficiency.

[0057] As a further optional embodiment, the step of, if the data to be stored is an atomic data type, converting the data type of the data to be stored into a preset data type by a type processor to obtain the target stored data specifically includes:

[0058] If the data to be stored is an atomic data type, the type processor extracts the value of the data to be stored to obtain the actual data value;

[0059] According to the actual data value and the data type of the actual data value, the target stored data is obtained.

[0060] If the data to be stored is an atomic data type, the type processor extracts the value of the data to be stored to obtain the actual data value; according to the actual data value and the data type of the actual data value, the target stored data is obtained.

[0061] Specifically, the type processor first extracts the actually stored value from the object of the atomic data type. Take AtomicReference <t>For example, AtomicReference encapsulates an object. The type handler obtains the actual data value stored in the object by calling the AtomicReference.get() method. If the data type is AtomicInteger, the encapsulated integer value is obtained by calling AtomicInteger.get().

[0062] After extracting the actual data value, the type handler needs to obtain the data type of the data value. The data type can be obtained through Java's reflection mechanism or by directly calling the object's method. For example, for the value in AtomicInteger, the data type is Integer, and for the value in AtomicLong, the data type is Long. In this way, the type handler can dynamically identify the actual type of the data.

[0063] Based on the extracted actual value and the data type of the value, the type handler converts the data into a preset data type supported by the database. For example, if the extracted data value is 42 of type AtomicInteger (type Integer), the type handler converts it to the Integer type; if the extracted data value is 10000000000L of type AtomicLong (type Long), the type handler will convert it to the Long type.

[0064] Finally, the data after data type conversion is returned as the target. This data type matches the field type in the database table and can be safely stored in the database.

[0065] Through the above steps, the type handler realizes the conversion from atomic data types to preset data types and ensures that the data stored in the database is consistent with the data type of the database fields.

[0066] Suppose the data to be stored is of type AtomicInteger with a value of 100. The execution process of the type handler is as follows:

[0067] Extract the data value: Extract the value 100 from AtomicInteger.

[0068] Obtain the data type: Confirm that the data type is Integer.

[0069] Data type conversion: Convert the value 100 to the Integer type (no conversion is required here because the value of AtomicInteger itself is of the Integer type).

[0070] Return the target data: The target data is 100 and the type is Integer.

[0071] Finally, the target data 100 will be stored in an Integer type field of the database.

[0072] By dynamically extracting and identifying the values of atomic data types in the type handler, this embodiment improves the flexibility of the data storage process. The type handler can automatically convert atomic data types into database types suitable for storage, reducing the burden on developers to manually convert data types. In this way, not only is the code simplified, but also the scalability and maintainability of the system are improved.

[0073] As a further optional embodiment, the type handler is obtained through the following steps:

[0074] Create a type handler that is used to convert the data type of the data to be processed into a preset data type;

[0075] Register the type handler into the MyBatis configuration file;

[0076] Create an entity class and a Mapper interface in MyBatis. The entity class is used to map the database table, and the Mapper interface is used to perform database operations.

[0077] Specifically, the type handler is used to convert the data type of the data to be processed into a preset data type. The type handler is usually a custom class that inherits from BaseTypeHandler or implements the TypeHandler interface. This class contains the specific data conversion logic. The type handler processes the conversion between atomic data types and preset data types by implementing methods such as setNonNullParameter, getNullableResult, and setNullableParameter.

[0078] After creating the type handler, it needs to be registered into the MyBatis configuration file to ensure that MyBatis can correctly use this type handler when performing SQL operations. Usually, it can be registered in the MyBatis configuration file mybatis-config.xml or injected through a Java configuration class.

[0079] In MyBatis, the entity class is used to map the database table, and the Mapper interface is used to perform database operations. The entity class is a POJO class that corresponds one-to-one with the fields in the database table. It can specify the mapping relationship with the database table through annotations or XML mapping files. The Mapper interface defines methods for interacting with the database, such as insert, query, update, and delete operations.

[0080] Through the above steps, the type handler is successfully registered and used in combination with the database operations of MyBatis, enabling developers to conveniently handle the conversion between atomic data types and database field data types. This not only reduces the duplicate code for data type conversion but also improves the maintainability and extensibility of the system.

[0081] As a further optional embodiment, after the step of creating an entity class and a Mapper interface in MyBatis, the method further includes:

[0082] Create a test object, the data type of which is an atomic data type;

[0083] Perform an insert operation on the test object;

[0084] When the data in the test object is successfully inserted into the database, the type handler is successfully registered.

[0085] In this step, first, a test object containing an atomic data type field needs to be created. This object can use the aforementioned entity class (such as the User class) and initialize the atomic data type field with test data. Suppose the field we are testing is status, and its data type is AtomicReference <string>。

[0086] In this step, the status field of the testUser object is initialized to an AtomicReference <string>The object stores the string "Active". This test object will be used to verify whether the type handler can correctly store atomic data types into the database.

[0087] After creating the test object, the insert operation is then performed. Assuming that we have defined a UserMapper interface and injected the corresponding type handler in the MyBatis configuration, then the testUser can be inserted into the database by calling the insertUser method.

[0088] At this time, the insertUser method will use the registered AtomicReferenceTypeHandler type handler to process AtomicReference <string>Data of a certain type, convert it to a preset data type supported by the database (such as String), and store the data in the database.

[0089] If the status field in testUser is successfully inserted into the database and no errors or exceptions occur, it means that the type handler has been successfully registered and is working properly. It can be verified through the following steps:

[0090] Query the database to confirm whether the data of the testUser object has been successfully inserted.

[0091] If the data is successfully inserted and AtomicReference <string>If the field status of the type is correctly stored as string-type data, it indicates that the type handler has been successfully registered.

[0092] If the value of the status field obtained from the database is "Active", it proves AtomicReference <string>The type data has been successfully converted to the String type in the database and stored, indicating the successful registration of the type handler.

[0093] The advantage of this further embodiment is that by creating a test object and performing an insert operation, it can be verified whether the type handler has correctly completed the data type conversion. If the insert operation is successful and the data type conversion meets the expectations, it can ensure the correct configuration and registration of the type handler in the system. This verification mechanism can ensure that in the actual production environment, atomic data types can be correctly processed and stored in the database, improving the reliability and stability of the system.

[0094] As a further optional embodiment, the atomic data type is AtomicReference <t>Type;

[0095] Wherein, T is a basic data type.

[0096] As a further optional embodiment of the present invention, the atomic data type is AtomicReference <t>Type, where T is a primitive data type. AtomicReference is an atomic class provided by Java, used to wrap references of any object type and provide atomic operations. To ensure data type consistency and facilitate storage, AtomicReference type is often used to wrap primitive data types (such as BigDecimal, Integer, Long, etc.), through which atomic operations can be achieved without being affected by multi-threaded concurrency issues.

[0097] Specifically, T can be one of the following primitive data types: BigDecimal, Integer, and Long.

[0098] In this way, AtomicReference <t>The type can manage the atomic reference of these basic data types and store them in the database through a type handler. When storing in the database, the AtomicReference type will be converted into a preset basic data type (such as BigDecimal, Integer, Long) for storage.

[0099] As a further optional embodiment, the basic data types include: BigDecimal, Integer, Long.

[0100] The basic data types include: BigDecimal, Integer, Long

[0101] In this embodiment, AtomicReference <t>The type T can be one of the following primitive data types:

[0102] BigDecimal: Used for high-precision numerical calculations, especially suitable for storing data such as currency and exchange rates in the financial field.

[0103] Integer: Used to represent integer values and is widely used for general integer data processing.

[0104] Long: Used to represent a large range of integer values and is suitable for storing larger numerical ranges.

[0105] These primitive data types are selected for AtomicReference <t>Type to meet the requirements for different data precisions and ranges. Whether it is a small range of integers or numerical calculations that require higher precision, they can be encapsulated by an appropriate AtomicReference to ensure the atomicity of the data storage process.

[0106] As a further optional embodiment, the preset data types include BigDecimal, Integer, Double, Boolean.

[0107] The preset data types include: BigDecimal, Integer, Double, Boolean

[0108] When storing atomic data types, the type processor will use AtomicReference <t>The data of the type is converted into a preset data type supported by the database. The preset data type may include:

[0109] BigDecimal: Suitable for high-precision floating-point data, often used in the financial or currency fields to ensure that data precision is not lost during storage.

[0110] Integer: Used for storing ordinary integer type data.

[0111] Double: Suitable for representing floating-point type data, especially when floating-point operations with a certain precision are required, the Double type is used to store data.

[0112] Boolean: Used for storing Boolean type data, representing yes / no or true / false.

[0113] Therefore, when the data is stored, if the original data type is AtomicReference <bigdecimal>, AtomicReference <integer>, AtomicReference <double>etc., the type handler will extract its value and convert it into the corresponding data type supported by the database. For example, AtomicReference <bigdecimal>Will be converted to BigDecimal, AtomicReference <integer>It will be converted to an Integer and stored in the database.

[0114] The storage device for atomic data provided by the present invention will be described below. As Figure 2 shown, the storage device for atomic data described below can be correspondingly referred to the storage method for atomic data described above.

[0115] A storage device for atomic data, comprising:

[0116] A data judgment module 210, configured to judge whether the data type of the data to be stored is an atomic data type in response to a database storage instruction;

[0117] A data judgment module 220, configured to, if the data to be stored is of an atomic data type, convert the data type of the data to be stored into a preset data type through a type processor to obtain target storage data;

[0118] A data storage module 230, configured to store the target storage data in the database.

[0119] Figure 3 The schematic physical structure diagram of an electronic device is exemplified. As Figure 3 shown, the electronic device may include: a processor 310, a communications interface 320, a memory 330, and a communication bus 340. Among them, the processor 310, the communications interface 320, and the memory 330 complete mutual communication through the communication bus 340. The processor 310 can call the logic instructions in the memory 330 to execute the storage method for atomic data, and the method includes:

[0120] Judge whether the data type of the data to be stored is an atomic data type in response to a database storage instruction;

[0121] If the data to be stored is of an atomic data type, convert the data type of the data to be stored into a preset data type through a type processor to obtain target storage data;

[0122] Store the target storage data in the database.

[0123] In addition, when the logical instructions in the above-mentioned memory 330 can be implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing 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 described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.

[0124] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the storage method of atomic data provided by the above-mentioned various methods. The method includes:

[0125] In response to a database storage instruction, determine whether the data type of the data to be stored is an atomic data type;

[0126] If the data to be stored is of an atomic data type, convert the data type of the data to be stored into a preset data type through a type processor to obtain target stored data;

[0127] Store the target stored data in the database.

[0128] On yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the storage method of atomic data provided by the above-mentioned various methods. The method includes:

[0129] In response to a database storage instruction, determine whether the data type of the data to be stored is an atomic data type;

[0130] If the data to be stored is of an atomic data type, convert the data type of the data to be stored into a preset data type through a type processor to obtain target stored data;

[0131] Store the target stored data in the database.

[0132] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative efforts.

[0133] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or equivalently replace some of the technical features. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / integer> < / bigdecimal> < / double> < / integer> < / bigdecimal> < / t> < / t> < / t> < / t> < / t> < / t> < / string> < / string> < / string> < / string> < / string> < / t> < / integer> < / t> < / t> < / t>

Claims

1. A method for storing atomic data, characterized in that: include: In response to a database storage instruction, determining whether the data type of the data to be stored is an atomic data type; If the data to be stored is of an atomic data type, the data type of the data to be stored is converted into a preset data type by a type processor to obtain target stored data; The target data is stored in a database.

2. The method for storing atomic data according to claim 1, characterized in that: If the data to be stored is an atomic data type, the step of converting the data type of the data to be stored into a preset data type by a type processor to obtain target stored data specifically includes: If the data to be stored is of atomic data type, the value of the data to be stored is extracted by a type processor to obtain the actual value of the data; The target stored data is obtained according to the actual value of the data and the data type of the actual value of the data.

3. The method for storing atomic data according to claim 1, characterized in that: The type processor is obtained by the following steps: Creating a type processor, wherein the type processor is used to convert the data type of the data to be processed into a preset data type; Register the type processor in the MyBatis configuration file; Create entity classes and Mapper interfaces in MyBatis, where the entity classes are used to map database tables and the Mapper interfaces are used to perform database operations.

4. The method for storing atomic data according to claim 3, characterized in that: After the step of creating the entity class and the Mapper interface in MyBatis, the method further comprises: Creating a test object, where the data type of the test object is an atomic data type; Performing an insert operation on the test object; When the data in the test object is successfully inserted into the database, the type processor is successfully registered.

5. The method for storing atomic data according to claim 1, characterized in that: The atomic data type is AtomicReference <t> type;< / t> Among them, T is a basic data type.

6. The method for storing atomic data according to claim 5, characterized in that: The basic data types include: BigDecimal, Integer, and Long.

7. The method for storing atomic data according to claim 1, characterized in that: The preset data types include BigDecimal, Integer, Double, and Boolean.

8. A storage device for atomic data, characterized in that: include: A data determination module, for determining whether the data type of the data to be stored is an atomic data type in response to a database storage instruction; A data judgment module, configured to convert the data type of the data to be stored into a preset data type through a type processor if the data to be stored is an atomic data type, so as to obtain target stored data; The data storage module is used to store the target data in a database.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the atomic data storage method as described in any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the atomic data storage method according to any one of claims 1 to 7 is implemented.