Database operation method, device and equipment and computer readable storage medium
By parsing the database operation request and combining the entity manager and the basic conversion adapter, the flexibility and reliability of the database operation are improved, the problems of database operation complexity and high cost in the existing technology are solved, and an efficient database operation method is provided. .
Patent Information
- Application Number
- CN202411070399.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-09-17
AI Technical Summary
Existing database operation methods have low flexibility when operating complex data, high development costs, low reliability, and complex operations, which increase the difficulty of development.
By parsing the database operation request, the entity manager and basic conversion adapter are used to convert the operation parameters into the target structured query language statement, and the persistent object tool or structured query language tool is selected according to the needs to perform database operations to achieve data type conversion and synchronization. .
It reduces development costs, improves development efficiency and reliability, simplifies the database operation process, reduces the difficulty of getting started, and supports operations of multiple data types.
Smart Images

Figure CN118656386A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to a database operation method, device, equipment and computer-readable storage medium. Background Art
[0002] When establishing an information system, the data generated in the system needs to be stored in a database. Therefore, a database connection toolkit needs to be introduced in the system backend framework to connect, send database operation statements and process results to meet business needs.
[0003] At present, there are many connection tools based on JDBC (Java Database Connectivity) on the market, such as JPA (Java Persistence API), Hibernate (object-relational mapping framework), MyBatis and other tools, which simplify the existing Java EE (Java Platform, Enterprise Edition, Java Enterprise Edition) Version) and Java SE (Java Standard Edition). In the process of dealing with complex business logic, there are two main options for database operation tools: one is to use tools that operate persistent objects (such as JPA, Hibernate) to update the data of the underlying persistent objects to the database; the other is to use tools that operate data (such as MyBatis), and the data is directly transferred to the database for execution through SQL (Structured Query Language) statements.
[0004] However, both of the above two database operation methods have their own shortcomings. First, the tools used to operate persistent objects have low flexibility when dealing with complex data operations. For persistent object tools, you need to learn their operation syntax and API (Application Programming Interface), which increases development costs in agile development. Secondly, when using structured query language tools to operate data, the data syntax operation is relatively complex when adding and updating data, and it is not object-oriented. The operated data is also non-persistent, and the data variables are not consistent with the database. The reliability is low, the operation of data is complex, and the development cost is increased.
[0005] In summary, how to effectively solve the problems of low flexibility, high development cost, low reliability, and complex operation of current database operation methods is an issue that technical personnel in this field urgently need to solve. Summary of the invention
[0006] The purpose of this application is to provide a database operation method, which reduces development costs, improves development efficiency, improves reliability, and reduces the difficulty of getting started; another purpose of this application is to provide a database operation device, equipment and computer-readable storage medium.
[0007] In order to solve the above technical problems, this application provides the following technical solutions:
[0008] A database operation method, comprising:
[0009] Parse the received database operation request to obtain the operation parameters, operation type and expected return data type;
[0010] When the operation type is a query operation, the operation parameters are converted into a target structured query language statement by using a native query support class that supports the native structured query language created by the entity manager, and the target structured query language statement is passed into the database for data query to obtain a query result;
[0011] Using a basic conversion adapter to convert the query result according to the expected returned data type to obtain a converted query result, and determining the converted query result as a database operation result;
[0012] When the operation type is a non-query operation,
[0013] The entity manager calls the operation method corresponding to the operation type to perform database operations.
[0014] In a specific implementation of the present application, the target structured query language statement is transferred to the database for data query, including:
[0015] The target structured query language statement is transmitted to the database according to a preset parameter transmission format for data query.
[0016] In a specific implementation of the present application, the entity manager calls the operation method corresponding to the operation type to perform a database operation, including:
[0017] Parsing the received operation tool selection instruction to obtain the target operation tool;
[0018] The entity manager calls the operation method corresponding to the operation type in the target operation tool to perform database operations.
[0019] In a specific implementation of the present application, the entity manager calls the operation method corresponding to the operation type in the target operation tool to perform database operation, including:
[0020] When the target operation tool is a structured query language tool, the database operation is performed by calling an update method through the native query support class.
[0021] In a specific implementation of the present application, the entity manager calls the operation method corresponding to the operation type in the target operation tool to perform database operation, including:
[0022] When the target operation tool is a persistent object operation tool and the operation type is data saving, obtaining the data to be saved;
[0023] The entity manager calls a persistence operation method to locally persist the data to be saved, and obtains a saving result;
[0024] The refresh method and the local persistence method are called to synchronize the saved results to the database.
[0025] In a specific implementation of the present application, the entity manager calls the operation method corresponding to the operation type in the target operation tool to perform database operation, including:
[0026] When the target operation tool is a persistent object operation tool and the operation type is data modification, obtaining the data to be modified;
[0027] The entity manager calls a merge operation method to perform local persistent update on the data to be modified to obtain a modification result;
[0028] The refresh method and the local persistence method are called to synchronize the modification results to the database.
[0029] In a specific implementation of the present application, the entity manager calls the operation method corresponding to the operation type in the target operation tool to perform database operation, including:
[0030] When the target operation tool is a persistent object operation tool and the operation type is data deletion, obtaining data to be deleted;
[0031] The entity manager calls a merge operation method to delete the data to be deleted from the persistent object to obtain a deletion result;
[0032] The refresh method and the local persistence method are called to synchronize the deletion result to the database.
[0033] A database operation device, comprising:
[0034] The request parsing module is used to parse the received database operation request to obtain the operation parameters, operation type and expected return data type;
[0035] A query result obtaining module, for, when the operation type is a query operation, using a native query support class supporting native structured query language created by an entity manager to convert the operation parameters into a target structured query language statement, and transferring the target structured query language statement into a database for data query to obtain a query result;
[0036] A type conversion module, used to convert the query result according to the expected returned data type using a basic conversion adapter to obtain a converted query result, and determine the converted query result as a database operation result;
[0037] The database operation module is used to perform database operation by calling the operation method corresponding to the operation type through the entity manager when the operation type is a non-query operation.
[0038] A database operation device, comprising:
[0039] Memory for storing computer programs;
[0040] A processor is used to implement the steps of the database operation method as described above when executing the computer program.
[0041] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the database operation method described above are implemented.
[0042] The database operation method provided in the present application parses the received database operation request to obtain operation parameters, operation type and expected return data type; when the operation type is a query operation, the operation parameters are converted into a target structured query language statement by using a native query support class that supports the native structured query language created by an entity manager, and the target structured query language statement is passed into the database for data query to obtain a query result; the query result is converted according to the expected return data type by using a basic conversion adapter to obtain a converted query result; the converted query result is determined as a database operation result; when the operation type is a non-query operation, the operation method corresponding to the operation type is called by the entity manager to perform a database operation.
[0043] It can be seen from the above technical solution that by integrating the operation persistence object tool and the structured query language operation data tool, the corresponding operation method can be flexibly selected according to the needs to perform database operations, which reduces the development cost, improves the development efficiency, and improves the reliability. By setting the basic conversion adapter to convert the data type of the query result, the converted query result of the expected returned data type is obtained, thereby realizing support for more data types and better meeting the development needs, thereby realizing the encapsulation of the underlying operations. When operating the converted query results, developers do not need to pay attention to how the underlying layer is implemented, but only need to pay attention to the logical level, and do not need to consider the problem of type conversion, which reduces the difficulty of getting started.
[0044] Correspondingly, the present application also provides a database operation device, equipment and computer-readable storage medium corresponding to the above-mentioned database operation method, which has the above-mentioned technical effects and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] FIG1 is a flowchart of an implementation of a database operation method in an embodiment of the present application;
[0047] FIG2 is another implementation flow chart of the database operation method in the embodiment of the present application;
[0048] FIG3 is a structural block diagram of a database operation device in an embodiment of the present application;
[0049] FIG4 is a structural block diagram of a database operation device in an embodiment of the present application;
[0050] FIG5 is a schematic diagram of the specific structure of a database operation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0052] Referring to FIG. 1 , FIG. 1 is a flowchart of an implementation of a database operation method in an embodiment of the present application. The method may include the following steps:
[0053] S101: Parse the received database operation request to obtain operation parameters, operation type and expected return data type.
[0054] When the user needs to operate the data in the database, a database operation request is generated and sent to the database operation control center. The database operation request contains operation parameters, operation type and expected return data type. The database operation control center receives the database operation request and parses it to obtain the operation parameters, operation type and expected return data type.
[0055] Operation parameters can include specific data information. For example, when you need to count the number of 18-year-old boys in a class, "18 years old" and "boys" are used as corresponding operation parameters. Operation types can include data query, data preservation, data modification, data deletion, etc. Data types can include byte, character, short, integer, long, double, float, Boolean, BigDecimal, string, map, and custom types.
[0056] The database operation control center may be a controller, a processor, etc. that includes the database operation tool in the embodiment of the present application.
[0057] S102: When the operation type is a query operation, the operation parameters are converted into a target structured query language statement using a native query support class that supports the native structured query language created by the entity manager, and the target structured query language statement is passed into the database for data query to obtain a query result.
[0058] A native query support class (NativeQuery) supporting native structured query language is created in advance through the JPA entity manager (EntityManager). After parsing the operation parameters, the operation parameters are converted into target structured query language statements using the native query support class supporting native structured query language created through the entity manager, and the target structured query language statement is passed to the database for data query to obtain the query results.
[0059] S103: using a basic conversion adapter to convert the query result according to the data type expected to be returned to obtain a converted query result, and determining the converted query result as a database operation result.
[0060] A basic transformer adapter (BasicTransformerAdapter) is pre-set for data type conversion. After parsing the operation type and querying the query result, the basic transformer adapter is used to convert the query result according to the expected return data type to obtain the converted query result, and the converted query result is directly determined as the database operation result, thereby completing this database operation.
[0061] The basic conversion adapter is compatible with various data types such as byte type, character type, short integer type, integer type, long integer type, double floating point type, single floating point type, Boolean type, exact calculation type, string type, character type and custom type.
[0062] S104: When the operation type is a non-query operation, the entity manager calls an operation method corresponding to the operation type to perform a database operation.
[0063] A corresponding operation method is pre-set for each operation type. When the operation type is a non-query operation, the operation method corresponding to the operation type is called by the entity manager to perform database operations.
[0064] It can be seen from the above technical solution that by integrating the operation persistence object tool and the structured query language operation data tool, the corresponding operation method can be flexibly selected according to the needs to perform database operations, which reduces the development cost, improves the development efficiency, and improves the reliability. By setting the basic conversion adapter to convert the data type of the query result, the converted query result of the expected returned data type is obtained, thereby realizing support for more data types and better meeting the development needs, thereby realizing the encapsulation of the underlying operations. When operating the converted query results, developers do not need to pay attention to how the underlying layer is implemented, but only need to pay attention to the logical level, and do not need to consider the problem of type conversion, which reduces the difficulty of getting started.
[0065] It should be noted that, based on the above embodiments, the embodiments of the present application also provide corresponding improved solutions. In the subsequent embodiments, the same steps or corresponding steps as those in the above embodiments can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be repeated one by one in the following improved embodiments.
[0066] Referring to FIG. 2 , FIG. 2 is another implementation flow chart of the database operation method in an embodiment of the present application. The method may include the following steps:
[0067] S201: Parse the received database operation request to obtain operation parameters, operation type and expected return data type.
[0068] S202: When the operation type is a query operation, the operation parameters are converted into target structured query language statements using the native query support class that supports the native structured query language created by the entity manager, and the target structured query language statement is passed to the database in a preset parameter transfer format for data query to obtain query results.
[0069] The parameter format is set in advance. After the target structured query language statement is parsed, the operation parameters are converted into the target structured query language statement using the native query support class that supports the native structured query language created by the entity manager, and the target structured query language statement is passed to the database in the preset parameter format for data query to obtain the query result. By passing parameters to the database in the standard preset parameter format, the data query efficiency is improved and the success rate of data query is increased.
[0070] The preset parameter passing format can include “?+subscript”, “:+variable name”, etc.
[0071] S203: using a basic conversion adapter to convert the query result according to the data type expected to be returned to obtain a converted query result, and determining the converted query result as a database operation result.
[0072] S204: When the operation type is a non-query operation, the received operation tool selection instruction is parsed to obtain a target operation tool.
[0073] The user end can send an operation tool selection instruction to the database operation control center according to actual needs. The database operation control center receives the operation tool selection instruction and parses the received operation tool selection instruction to obtain the target operation tool.
[0074] The target operation tool is any one of a tool for operating persistent objects and a tool for operating data using a structured query language.
[0075] S205: Calling the operation method corresponding to the operation type in the target operation tool through the entity manager to perform database operation.
[0076] Different operation tools use different operation methods for the same operation type. After parsing the target operation tool, the entity manager calls the operation method corresponding to the operation type in the target operation tool to perform database operations. By setting the user end to select the database operation tool according to actual needs, the database operation process is simplified and the user experience is improved.
[0077] In a specific implementation of the present application, step S206 may include the following steps:
[0078] When the target operation tool is a structured query language tool, the update method is called through the native query support class to perform database operations.
[0079] When the target operation tool is a structured query language tool, the executeUpdate method is called through the native query support class to perform database operations. The executable structured query languages include creating database tables (create), inserting new data items into database tables (insert), updating data in database tables (update), deleting data from database tables (delete), deleting database objects such as tables, views, indexes, etc. (drop), quickly clearing all data in database tables (truncate), and other scripting languages, such as keywords for declaring and defining variables (declare), etc. It fully utilizes the advantages of the structured query language tool, which has no usage threshold, high flexibility, and powerful functions.
[0080] In a specific implementation of the present application, step S206 may include the following steps:
[0081] Step 1: When the target operation tool is a persistent object operation tool and the operation type is data saving, obtain the data to be saved;
[0082] Step 2: Call the persistence operation method through the entity manager to locally persist the data to be saved and obtain the saved result;
[0083] Step 3: Call the refresh method and local persistence method to synchronize the saved results to the database.
[0084] For the convenience of description, the above three steps can be combined for explanation.
[0085] When the target operation tool is a persistent object operation tool and the operation type is data preservation, the data to be saved is obtained, and the persistent operation (persist) method is called through the entity manager to locally persist the data to be saved, and the saved result is obtained. The refresh method (flush) and the local persistence (clear) method are called to synchronize the saved result to the database. The persistent preservation of the data to be saved using the persistent object operation tool is realized, which ensures data consistency and simple operation.
[0086] In a specific implementation of the present application, step S206 may include the following steps:
[0087] Step 1: When the target operation tool is a persistent object operation tool and the operation type is data modification, obtain the data to be modified;
[0088] Step 2: Call the merge operation method through the entity manager to perform local persistent update on the data to be modified and obtain the modification result;
[0089] Step 3: Call the refresh method and local persistence method to synchronize the modification results to the database.
[0090] For the convenience of description, the above three steps can be combined for explanation.
[0091] When the target operation tool is a persistent object operation tool and the operation type is data modification, the data to be modified is obtained, and the merge operation method is called through the entity manager to perform local persistent update on the data to be modified, and the modification result is obtained. The refresh method and the local persistence method are called to synchronize the modification result to the database. The persistent update of the modified data using the persistent object operation tool is realized, which ensures data consistency and simple operation.
[0092] In a specific implementation of the present application, step S206 may include the following steps:
[0093] Step 1: When the target operation tool is a persistent object operation tool and the operation type is data deletion, obtain the data to be deleted;
[0094] Step 2: Call the merge operation method through the entity manager to delete the data to be deleted from the persistent object and obtain the deletion result;
[0095] Step 3: Call the refresh method and local persistence method to synchronize the deletion results to the database.
[0096] For the convenience of description, the above three steps can be combined for explanation.
[0097] When the target operation tool is a persistent object operation tool and the operation type is data deletion, the data to be deleted is obtained, and the merge operation method is called through the entity manager to delete the data to be deleted from the persistent object, and the deletion result is obtained. The refresh method and the local persistence method are called to synchronize the deletion result to the database. The persistent deletion of the data to be deleted using the persistent object operation tool is realized, which ensures data consistency and simple operation.
[0098] Corresponding to the above method embodiment, the present application also provides a database operation device. The database operation device described below and the database operation method described above can refer to each other.
[0099] Referring to FIG. 3 , FIG. 3 is a structural block diagram of a database operation device in an embodiment of the present application, and the device may include:
[0100] The request parsing module 31 is used to parse the received database operation request to obtain the operation parameters, operation type and expected return data type;
[0101] The query result obtaining module 32 is used for, when the operation type is a query operation, using the native query support class supporting the native structured query language created by the entity manager to convert the operation parameters into a target structured query language statement, and passing the target structured query language statement into the database for data query to obtain the query result;
[0102] The type conversion module 33 is used to convert the query result according to the expected returned data type by using the basic conversion adapter to obtain the converted query result, and determine the converted query result as the database operation result;
[0103] The database operation module 34 is used to perform database operations by calling an operation method corresponding to the operation type through the entity manager when the operation type is a non-query operation.
[0104] It can be seen from the above technical solution that by integrating the operation persistence object tool and the structured query language operation data tool, the corresponding operation method can be flexibly selected according to the needs to perform database operations, which reduces the development cost, improves the development efficiency, and improves the reliability. By setting the basic conversion adapter to convert the data type of the query result, the converted query result of the expected returned data type is obtained, thereby realizing support for more data types and better meeting the development needs, thereby realizing the encapsulation of the underlying operations. When operating the converted query results, developers do not need to pay attention to how the underlying layer is implemented, but only need to pay attention to the logical level, and do not need to consider the problem of type conversion, which reduces the difficulty of getting started.
[0105] In a specific implementation of the present application, the query result obtaining module 32 is specifically a module that transmits the target structured query language statement to the database according to a preset parameter transmission format for data query.
[0106] In a specific implementation of the present application, the database operation module 34 includes:
[0107] The operation tool acquisition submodule is used to parse the received operation tool selection instruction to obtain the target operation tool;
[0108] The database operation submodule is used to perform database operations by calling the operation method corresponding to the operation type in the target operation tool through the entity manager.
[0109] In a specific implementation of the present application, the database operation submodule is specifically a module that performs database operations by calling an execution update method through a native query support class when the target operation tool is a structured query language tool.
[0110] In a specific implementation of the present application, the database operation submodule includes:
[0111] The to-be-saved data acquisition unit is used to acquire the to-be-saved data when the target operation tool is a persistent object operation tool and the operation type is data saving;
[0112] A saving result obtaining unit is used to call a persistence operation method through an entity manager to locally persist the data to be saved and obtain a saving result;
[0113] The save result synchronization unit is used to call the refresh method and the local persistence method to synchronize the save result to the database.
[0114] In a specific implementation of the present application, the database operation submodule includes:
[0115] The to-be-modified data acquisition unit is used to acquire the to-be-modified data when the target operation tool is a persistent object operation tool and the operation type is data modification;
[0116] A modification result obtaining unit is used to perform local persistent update on the data to be modified by calling a merge operation method through an entity manager to obtain a modification result;
[0117] The modification result synchronization unit is used to call the refresh method and the local persistence method to synchronize the modification results to the database.
[0118] In a specific implementation of the present application, the database operation submodule includes:
[0119] A to-be-deleted data acquisition unit, used to acquire the to-be-deleted data when the target operation tool is a persistent object operation tool and the operation type is data deletion;
[0120] A deletion result obtaining unit is used to delete the data to be deleted from the persistent object by calling a merge operation method through the entity manager to obtain a deletion result;
[0121] The deletion result synchronization unit is used to call the refresh method and the local persistence method to synchronize the deletion results to the database.
[0122] Corresponding to the above method embodiment, referring to FIG. 4 , FIG. 4 is a schematic diagram of a database operation device provided by the present application, and the device may include:
[0123] A memory 332, for storing computer programs;
[0124] The processor 322 is used to implement the steps of the database operation method of the above method embodiment when executing the computer program.
[0125] Specifically, please refer to FIG. 5 , which is a schematic diagram of the specific structure of a database operation device provided in this embodiment. The database operation device may have relatively large differences due to different configurations or performances, and may include a processor (central processing units, CPU) 322 (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 may be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the database operation device 301.
[0126] The database operating device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0127] The steps in the database operating method described above can be implemented by the structure of the database operating device.
[0128] Corresponding to the above method embodiment, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps can be implemented:
[0129] Parse the received database operation request to obtain the operation parameters, operation type and expected return data type; when the operation type is a query operation, use the native query support class that supports the native structured query language created by the entity manager to convert the operation parameters into a target structured query language statement, and pass the target structured query language statement into the database for data query to obtain the query result; use the basic conversion adapter to convert the query result according to the expected return data type to obtain the converted query result; determine the converted query result as the database operation result; when the operation type is a non-query operation, call the operation method corresponding to the operation type through the entity manager to perform the database operation.
[0130] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0131] For an introduction to the computer-readable storage medium provided in this application, please refer to the above method embodiment, and this application will not go into details here.
[0132] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the devices, equipment and computer-readable storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0133] Specific examples are used herein to illustrate the principles and implementation methods of the present application, and the description of the above embodiments is only used to help understand the technical solution and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
Claims
1. A database operation method, characterized in that: include: Parse the received database operation request to obtain the operation parameters, operation type and expected return data type; When the operation type is a query operation, the operation parameters are converted into a target structured query language statement by using a native query support class that supports the native structured query language created by the entity manager, and the target structured query language statement is passed into the database for data query to obtain a query result; Using a basic conversion adapter to convert the query result according to the expected returned data type to obtain a converted query result, and determining the converted query result as a database operation result; When the operation type is a non-query operation, the entity manager calls an operation method corresponding to the operation type to perform a database operation.
2. The database operation method according to claim 1, characterized in that: The target structured query language statement is transferred into the database for data query, including: The target structured query language statement is transmitted to the database according to a preset parameter transmission format for data query.
3. The database operation method according to claim 1 or 2, characterized in that: Calling the operation method corresponding to the operation type through the entity manager to perform database operations includes: Parsing the received operation tool selection instruction to obtain the target operation tool; The entity manager calls the operation method corresponding to the operation type in the target operation tool to perform database operations.
4. The database operation method according to claim 3, characterized in that: Calling the operation method corresponding to the operation type in the target operation tool through the entity manager to perform database operation includes: When the target operation tool is a structured query language tool, the database operation is performed by calling an update method through the native query support class.
5. The database operation method according to claim 3, characterized in that: Calling the operation method corresponding to the operation type in the target operation tool through the entity manager to perform database operation includes: When the target operation tool is a persistent object operation tool and the operation type is data saving, obtaining the data to be saved; The entity manager calls a persistence operation method to locally persist the data to be saved, and obtains a saving result; The refresh method and the local persistence method are called to synchronize the saved results to the database.
6. The database operation method according to claim 3, characterized in that: Calling the operation method corresponding to the operation type in the target operation tool through the entity manager to perform database operation includes: When the target operation tool is a persistent object operation tool and the operation type is data modification, obtaining the data to be modified; The entity manager calls a merge operation method to perform local persistent update on the data to be modified to obtain a modification result; The refresh method and the local persistence method are called to synchronize the modification results to the database.
7. The database operation method according to claim 3, characterized in that: Calling the operation method corresponding to the operation type in the target operation tool through the entity manager to perform database operation includes: When the target operation tool is a persistent object operation tool and the operation type is data deletion, obtaining data to be deleted; The entity manager calls a merge operation method to delete the data to be deleted from the persistent object to obtain a deletion result; The refresh method and the local persistence method are called to synchronize the deletion result to the database.
8. A database operation device, characterized in that: include: The request parsing module is used to parse the received database operation request to obtain the operation parameters, operation type and expected return data type; A query result obtaining module, for, when the operation type is a query operation, using a native query support class supporting native structured query language created by an entity manager to convert the operation parameters into a target structured query language statement, and transferring the target structured query language statement into a database for data query to obtain a query result; A type conversion module, used to convert the query result according to the expected returned data type using a basic conversion adapter to obtain a converted query result, and determine the converted query result as a database operation result; The database operation module is used to perform database operation by calling the operation method corresponding to the operation type through the entity manager when the operation type is a non-query operation.
9. A database operation device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the database operation method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the database operation method according to any one of claims 1 to 7 are implemented.
