Database access system, method, computer device and storage medium

By introducing an ORM execution engine, application systems no longer need to directly connect to the database. Instead, they interact with the database solely through the ORM execution engine. This solves the security and management complexity issues caused by configuring database passwords in multiple application systems, and enables secure and controllable database management.

CN115729912BActive Publication Date: 2026-04-10HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU QULIAN TECHNOLOGY CO LTD
Filing Date
2022-11-08
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

When multiple application systems need to access the same database, each application system needs to configure a database account and password, which reduces database security, makes it impossible to manage database access in a unified manner, and increases configuration complexity and security risks.

Method used

An ORM execution engine is introduced. The first ORM framework generates operation requests, and the second ORM framework parses and executes SQL statements to achieve database access. The application system does not need to connect to the database directly, but only interacts with the database through the ORM execution engine. The database password is configured in the ORM execution engine.

Benefits of technology

It improves database security, reduces configuration complexity, controls the number of TCP connections, supports more advanced access management, ensures database security and controllability, and reduces the development complexity of application systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115729912B_ABST
    Figure CN115729912B_ABST
Patent Text Reader

Abstract

The application discloses a database access system, method, computer device and storage medium, and belongs to the technical field of computers. The database access system comprises an application system and an ORM execution engine, the application system comprises a first ORM framework, the ORM execution engine comprises a second ORM framework, and the ORM execution engine is in communication connection with a database; the first ORM framework is used for generating an operation request according to a business statement, and sending the operation request to the ORM execution engine; the second ORM framework is used for parsing the operation request to obtain a SQL statement after the operation request is acquired; and the SQL statement is executed to access data in the database. In the application, the application system does not need to be directly connected with the database, so that the password of the database does not need to be configured in the application system, and the ORM execution engine only needs to interact with the database to realize access to the database, so that the security of the database is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a database access system and method, computer device and storage medium. BACKGROUND

[0002] For an application system, a large amount of business data is stored in a database, and the application system often needs to access the database when performing business operations to read, modify or store business data.

[0003] In the related art, after configuring the account and password of the database in each application system, the application system can directly interact with the database. An ORM (Object Relational Mapping) framework is integrated in each application system. The ORM framework can automatically compile the object-oriented program language written by a technical personnel into a database operation language that can be recognized by the database. In this case, the technical personnel can write an object-oriented business program in the application system, and then the ORM framework executes the business program to automatically compile the business program into an operation program that can be recognized by the database, and executes the operation program to access the database.

[0004] However, in the case that multiple application systems need to access the same database, each application system in the multiple application systems needs to configure the account and password of the database, so that each application system knows the account and password of the database. The widespread use of such private data can cause great security risks to the database, thereby reducing the security of the database. SUMMARY

[0005] The present application provides a database access system and method, computer device and storage medium, which can improve the security of the database. The technical solution is as follows:

[0006] In a first aspect, a database access system is provided, which includes an application system and a relational object mapping (ORM) execution engine. The application system includes a first ORM framework, and the ORM execution engine includes a second ORM framework. The ORM execution engine is in communication connection with a database.

[0007] The first ORM framework is configured to generate an operation request according to a business statement, and send the operation request to the ORM execution engine. The operation request is used to request an operation on data in the database.

[0008] The second ORM framework is configured to, after obtaining the operation request, parse the operation request to obtain a structured query language (SQL) statement, execute the SQL statement to access data in the database, and obtain an execution result of the SQL statement.

[0009] In the present application, the application system comprises a first ORM framework, the ORM execution engine comprises a second ORM framework, and the ORM execution engine is in communication connection with the database. The first ORM framework generates an operation request according to a business statement, and sends the operation request to the ORM execution engine, that is, the application system sends an operation request to the ORM execution engine when needing to access the database. Then, the second ORM framework in the ORM execution engine receives the operation request, parses the operation request to obtain a SQL statement, and executes the SQL statement to access data in the database. In this way, the application system does not need to be directly connected to the database, and thus the password of the database does not need to be configured in the application system, but the ORM execution engine interacts with the database to realize access to the database, thereby ensuring the security of the database.

[0010] In a second aspect, a database access method is provided, which is applied to an object-relational mapping (ORM) execution engine. The ORM execution engine comprises a second ORM framework, is in communication connection with an application system, and is in communication connection with a database. The application system comprises a first ORM framework. The method comprises the following steps.

[0011] The second ORM framework obtains an operation request sent by the first ORM framework. The operation request is generated by the first ORM framework according to a business statement, and is used to request operation on data in the database.

[0012] The second ORM framework parses the operation request to obtain a structured query language (SQL) statement after obtaining the operation request.

[0013] The second ORM framework executes the SQL statement to access data in the database, and obtains an execution result of the SQL statement.

[0014] In the present application, the ORM execution engine comprises a second ORM framework, the ORM execution engine is in communication connection with an application system, and the ORM execution engine is in communication connection with a database, the application system comprising a first ORM framework. The second ORM framework in the ORM execution engine acquires an operation request sent by the first ORM framework, the operation request being generated by the first ORM framework according to a business statement, that is, the application system sends an operation request to the ORM execution engine when needing to access the database. Then the second ORM framework parses the operation request to obtain a SQL statement, the SQL statement being a statement recognizable by the database. The second ORM framework executes the SQL statement to access data in the database. In this way, the application system does not need to directly connect the database, and thus the password of the database does not need to be configured in the application system, and the ORM execution engine only needs to interact with the database to realize access to the database, thereby ensuring the security of the database.

[0015] In a third aspect, a computer device is provided, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program, when executed by the processor, implements the database access method described above.

[0016] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program, and the computer program, when executed by a processor, implements the database access method described above.

[0017] In a fifth aspect, a computer program product containing instructions, which, when executed on a computer, causes the computer to perform the steps of the database access method described above.

[0018] It can be understood that the beneficial effects of the third aspect, the fourth aspect, and the fifth aspect described above can be referred to the related description in the second aspect described above, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0020] Figure 1 is a structural schematic diagram of a database access system provided by the embodiments of the present application;

[0021] Figure 2 is a flowchart of a database access method provided by the embodiments of the present application;

[0022] Figure 3 is a schematic diagram of an operation request provided by an embodiment of the present application;

[0023] Figure 4 is a schematic diagram of interaction between an application system and an ORM execution engine provided by an embodiment of the present application;

[0024] Figure 5 is a flowchart of another database access method provided by an embodiment of the present application;

[0025] Figure 6 is a flowchart of yet another database access method provided by an embodiment of the present application;

[0026] Figure 7 is a flowchart of still another database access method provided by an embodiment of the present application;

[0027] Figure 8 is a schematic diagram of interaction between an application system and an ORM execution engine provided by an embodiment of the present application;

[0028] Figure 9 is a structural schematic diagram of another database access system provided by an embodiment of the present application;

[0029] Figure 10 is a structural schematic diagram of yet another database access system provided by an embodiment of the present application;

[0030] Figure 11 is a schematic diagram of a middleware module provided by an embodiment of the present application;

[0031] Figure 12 is a structural schematic diagram of still another database access system provided by an embodiment of the present application;

[0032] Figure 13 is a structural schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical scheme and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0034] It should be understood that the "multiple" mentioned in the present application refers to two or more than two. In the description of the present application, unless otherwise specified, " / " represents the meaning of or, for example, A / B can represent A or B; "and / or" herein only describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. In addition, in order to clearly describe the technical solutions of the present application, the same items or similar items with basically the same function and role are distinguished by using "first", "second", etc. The skilled in the art can understand that "first", "second", etc. do not limit the quantity and execution order, and "first", "second", etc. also do not limit the difference.

[0035] Before the embodiments of the present application are explained in detail, the application scenarios of the embodiments of the present application are described.

[0036] First, the ORM framework involved in the application scenario is described.

[0037] The business logic layer and the user interface layer are object-oriented, and when the information of the object changes, the information of the object needs to be saved in the database (including but not limited to relational database). However, updating the data in the database cannot use object-oriented language, so very complex database language needs to be written to update the data in the database.

[0038] The ORM framework is a technology to solve the language mismatch between object-oriented and database. Specifically, by describing the metadata mapping between objects and databases, the objects in the program are automatically persisted to the database, that is, the ORM framework is a bridge connecting the business logic layer and the database. Generally, a persistent class in the metadata corresponds to a table in the database, each instance of the class corresponds to a record in the table, and each property of the class corresponds to each field of the table.

[0039] Since the ORM framework provides a mapping between the database and the object, when operating the data in the database, we no longer need to deal with complex database language, but can operate it as usual. The ORM framework can make the development more object-oriented, and for technical personnel, only object-oriented business programs need to be written, which makes program writing more convenient, so as to improve the development efficiency and reduce the development cost.

[0040] Generally, an application system based on an ORM framework accesses a database by directly connecting with the database. Specifically, an ORM framework in the application system executes a business program written by a technical personnel to automatically compile the business program into an operation statement (SQL statement in the embodiment of the present application) recognizable by the database, and executes the operation statement to access the database. In this case, the following problems exist.

[0041] First, an account and a password of the database need to be configured in each application system accessing the same database. In this case, on the one hand, the configuration complexity of the application system is increased, and on the other hand, the account and the password of the database are known by each application system, which brings great security risks to the database.

[0042] Second, the database is provided with a maximum TCP (Transmission Control Protocol) connection number, that is, the database only allows a limited number of application systems to be connected. The connection of each application system with the database consumes the TCP connection number of the database, and the TCP connection number consumed by the application system is defined by the application system itself, that is, the application system can define the TCP connection number of the application system with the database. For the database, the overall TCP connection number is uncontrollable. Considering an extreme case, if the TCP connection number defined by an application system is the maximum TCP connection number supported by the database, then the remaining application systems cannot be connected to the database, thereby affecting the performance of the remaining application systems.

[0043] Third, the direct connection mode of the application system and the database cannot comprehensively manage the entire database access. Although the database is provided with some management and control configurations, it cannot meet all business requirements and cannot realize higher, special and self-defined restriction functions on the entire database access, such as user system authentication, black and white list, flow control and the like.

[0044] Fourth, if the database itself needs to be replaced (for example, from a MySQL database to a PostgreSQL database), all application systems need to synchronously update the related codes and configurations at the database level. In this case, the complexity of the application system is high, and if the synchronous update fails, problems in deployment, operation and maintenance, development and the like are easily caused.

[0045] Fifth, the application system itself does not have data caching capability, and since the table operation of one application system on the database can be modified at any time by other application systems, even if the data is cached in the application system, the effectiveness of the cache cannot be guaranteed.

[0046] Therefore, this application provides a database access method. When database access is required, the application system can send an operation request to the ORM execution engine. The ORM execution engine can then process the operation request and interact with the database to achieve database access. In this way, the application system does not need to directly connect to the database, and therefore does not need to configure a database password, thus ensuring database security.

[0047] The system architecture involved in the embodiments of this application will be described below.

[0048] Figure 1 This is a schematic diagram of a database access system provided in an embodiment of this application. See also... Figure 1 The database access system includes: application system 101 and ORM execution engine 102.

[0049] Application system 101 includes a first ORM framework, which generates operation requests when access to database 103 is required. Application system 101 can be deployed on a terminal or a server, and can communicate with ORM execution engine 102 via a wired or wireless connection. There can be one or more application systems 101, and multiple application systems 101 can communicate with ORM execution engine 102.

[0050] The database access system may include one or more ORM execution engines 102. These multiple ORM execution engines 102, acting as an ORM execution engine cluster, communicate with one or more application systems 101. Furthermore, these multiple ORM execution engines 102 also act as an ORM execution engine cluster to communicate with the database 103. Each ORM execution engine 102 includes a second ORM framework, which processes received operation requests and interacts with the database 103. The ORM execution engine 102 can be deployed on a server, which may be a single server or a server cluster consisting of multiple servers.

[0051] The ORM execution engine 102 can communicate with the database 103 via wired or wireless connection, and can also communicate with the application system 101 via wired or wireless connection.

[0052] For example, when the application system 101 needs to access data in the database 103, the first ORM framework in the application system 101 generates an operation request for accessing the database 103 and sends the operation request to the ORM execution engine 102. The second ORM framework in the ORM execution engine 102 receives the operation request and processes the operation request, and interacts with the database 103 to implement the operation on the data in the database 103.

[0053] In the embodiment of the present application, the ORM execution engine 102 directly communicates with the database 103, and the application system 101 does not need to directly communicate with the database 103, but accesses the database 103 through the ORM execution engine 102, so that the application system 101 does not need to configure the password of the database 103, but only needs to configure the password of the database 103 in the ORM execution engine 102. In the embodiment of the present application, in the case that there is only one ORM execution engine 102 in the database access system, the password of the database 103 only needs to be configured in the ORM execution engine 102; in the case that there are multiple ORM execution engines 102 in the database access system, the password of the database 103 only needs to be configured in the ORM execution engine cluster composed of the multiple ORM execution engines 102. The application system is a user-oriented system, and its security level is lower than that of the ORM execution engine 102, that is, the security level of the ORM execution engine 102 is higher, so compared with the scheme in the related art in which multiple application systems directly communicate with the database and the password of the database is configured in the multiple application systems, the database access system provided in the embodiment of the present application configures the password of the database 103 in the ORM execution engine 102, which can improve the security of the database 103.

[0054] The database access method provided in the embodiment of the present application will be explained and described in detail below.

[0055] Figure 2 is a flowchart of a database access method provided in the embodiment of the present application. The database access method is applied to the database access system described in the embodiment of the present application. Figure 1 Figure 2 The method includes the following steps.

[0056] Step 201: The first ORM framework generates an operation request according to a business statement.

[0057] ​The business statement is a statement written by a technical person using an object-oriented programming language. Optionally, the first ORM framework integrated in the application system can be an ORM-based SDK (Software Development Kit) deployed in the application system. In this case, the technical person can directly write the object-oriented business statement using the program syntax of the ORM. Then the first ORM framework can generate an operation request according to the business statement written by the technical person. The operation request is used to request an operation on data in the database.

[0058] In the embodiment of the present application, the first ORM framework encapsulates the result obtained by parsing the business statement to obtain an operation request when the application system calls the business statement. In this way, the operation request includes information related to the business statement, that is, information related to the operation on the database. Optionally, the operation request can include object identifier, operation type, original data of the object identified by the object identifier, update data of the object identified by the object identifier, and the like.

[0059] The object identifier is an identifier of an object in the database to be accessed by the application system. For example, the object identifier can be a table name in the database, which is not limited in the embodiment of the present application. The operation type is a type of operation on the object in the database by the application system. For example, the operation type can include INSERT, DELETE, UPDATE, and FIND.

[0060] For example, Figure 3 A data schematic diagram of the operation request is shown in FIG. 2B. Figure 3 The operation request shown in FIG. 2B includes operation type, table name, original table data, original SQL data, update data, and the like, which are related to the operation on the database.

[0061] Step 202: The first ORM framework sends the operation request to the ORM execution engine.

[0062] In the embodiment of the present application, the first ORM framework provides an interface for communication connection with the ORM execution engine. In this way, the first ORM framework in the application system can send the operation request to the ORM execution engine through the interface after generating the operation request.

[0063] As an example, the user wants to view the order information of the account, and the user can click the query button of the order information in an application system to trigger the operation of accessing the order information of the account in the database. At this time, the application system can call the business statement of querying the order information, and the first ORM framework can encapsulate the business statement to obtain the corresponding operation request, and send the operation request to the ORM execution engine. The operation request is a request for querying the order information of the account of the user from the database. The ORM execution engine can perform corresponding processing after receiving the operation request, and can perform the following steps 203-205.

[0064] Step 203: The second ORM framework in the ORM execution engine obtains the operation request.

[0065] The second ORM framework is an ORM framework integrated in the ORM execution engine, and is used to process the operation request after obtaining the operation request to implement the access operation to the database.

[0066] In this case, the second ORM framework in the ORM execution engine can know that the application system wants to access the database after obtaining the operation request.

[0067] In a possible implementation, the first ORM framework in the application system can directly communicate with the second ORM framework in the ORM execution engine. In this case, the operation request sent by the first ORM framework to the ORM execution engine can be directly received by the second ORM framework, that is, the second ORM framework can directly receive the operation request sent by the first ORM framework.

[0068] In another possible implementation, the ORM execution engine includes a middleware module, and the middleware module can be in communication connection with the application system, that is, the middleware module can directly communicate with the first ORM framework. In this case, the operation request sent by the first ORM framework to the ORM execution engine can be directly received by the middleware module. The middleware module can first receive the operation request sent by the first ORM framework, and then send the operation request to the second ORM framework in the case of satisfying the database access condition.

[0069] The database access condition can be set in advance, and the database access condition can be set by a technician according to a business requirement. Optionally, the database access condition can include at least one of the following items:

[0070] First, the access times of the database are less than a first number threshold.

[0071] The first number threshold is the maximum number of times that the database can be accessed within a certain period (such as a day, a month, etc.). The first number threshold can be set in advance, and the first number threshold can be set by a technician according to business needs.

[0072] In this case, the number of accesses to the database is less than the first number threshold, indicating that the number of accesses to the database has not reached the maximum number of times that the database can be accessed. Therefore, the database can continue to be accessed, and the middleware module can send the operation request to the second ORM framework. The number of accesses to the database is greater than or equal to the first number threshold, indicating that the number of accesses to the database has exceeded the maximum number of times that the database can be accessed. Therefore, the database cannot continue to be accessed, and the middleware module cannot send the operation request to the second ORM framework.

[0073] For example, the first number threshold is 10, and the current number of accesses to the database is 5. The current number of accesses to the database (5) is less than the first number threshold (10), so it can be determined that this access satisfies the database access condition, and the middleware module can send the operation request to the second ORM framework.

[0074] Second, the number of accesses to the object to be accessed by the operation request is less than the second number threshold.

[0075] The second number threshold is the maximum number of times that the object to be accessed by the operation request can be accessed within a certain period (such as a day, a month, etc.). The second number threshold can be set in advance, and the second number threshold can be set by a technician according to business needs.

[0076] In this case, the number of accesses to the object to be accessed by the operation request is less than the second number threshold, indicating that the number of accesses to the object to be accessed by the operation request has not reached the maximum number of times that the object to be accessed by the operation request can be accessed. Therefore, the database can continue to be accessed, and the middleware module can send the operation request to the second ORM framework. The number of accesses to the object to be accessed by the operation request is greater than or equal to the second number threshold, indicating that the number of accesses to the object to be accessed by the operation request has exceeded the maximum number of times that the object to be accessed by the operation request can be accessed. Therefore, the database cannot continue to be accessed, and the middleware module cannot send the operation request to the second ORM framework.

[0077] For example, the second number threshold is 5, and the current number of accesses to the object to be accessed by the operation request is 3. The current number of accesses to the object to be accessed by the operation request (3) is less than the second number threshold (5), so it can be determined that the operation request satisfies the database access condition, and the middleware module can send the operation request to the second ORM framework.

[0078] Third, the application system has access permission of the object accessed by the operation request.

[0079] The access permission of the object accessed by the operation request is used to limit the access of part of the application system to the object accessed by the operation request, that is, the application system having the access permission of the object accessed by the operation request is allowed to access the object, and the application system not having the access permission of the object accessed by the operation request is not allowed to access the object. The access permission of the object accessed by the operation request can be set by the technician according to the business requirement.

[0080] After the middleware module receives the operation request, it can first verify whether the application system sending the operation request has the access permission of the object accessed by the operation request. If the application system has the access permission of the object accessed by the operation request, it means that the application system is allowed to access the object accessed by the operation request, and then the database can be accessed, so the middleware module can send the operation request to the second ORM framework. If the application system does not have the access permission of the object accessed by the operation request, it means that the application system is not allowed to access the object accessed by the operation request, and then the database cannot be accessed, so the middleware module cannot send the operation request to the second ORM framework.

[0081] Fourth, the application system has access permission of the database.

[0082] The access permission of the database is used to limit the access of part of the application system to the database. That is, the application system having the access permission of the database is allowed to access the database, and the application system not having the access permission of the database is not allowed to access the database. The access permission of the database can be set by the technician according to the business requirement.

[0083] After the middleware module receives the operation request, it can first verify whether the application system sending the operation request has the access permission of the database. If the application system has the access permission of the database, it means that the application system is allowed to access the database, and then the database can be accessed, so the middleware module can send the operation request to the second ORM framework. If the application system does not have the access permission of the database, it means that the application system is not allowed to access the database, and then the database cannot be accessed, so the middleware module cannot send the operation request to the second ORM framework.

[0084] Fifth, the operation type in the operation request is the operation type allowed by the database to the object accessed by the operation request.

[0085] The technician can set the operation type of the object in the database that can be operated according to the business requirement, so as to limit the operation of the application system to the object in the database.

[0086] After receiving the operation request, the middleware module can first check whether the operation type in the operation request is an operation type allowed by the database to be performed on the object accessed by the operation request. If the operation type in the operation request is an operation type allowed by the database to be performed on the object accessed by the operation request, it indicates that the operation type intended by the operation request to be performed on the object is an allowed operation type, and then the database can be accessed, and the middleware module can send the operation request to the second ORM framework. If the operation type in the operation request is not an operation type allowed by the database to be performed on the object accessed by the operation request, it indicates that the operation type intended by the operation request to be performed on the object is an unallowed operation type, and then the database cannot be accessed, and the middleware module cannot send the operation request to the second ORM framework.

[0087] Of course, in the embodiment of the present application, the middleware module can send the operation request to the second ORM framework when any one of the above five conditions is met; or the middleware module sends the operation request to the second ORM framework when multiple conditions of the above five conditions are met. In addition, in addition to the above five conditions, the skilled person can also set other conditions, and the embodiment of the present application does not limit this.

[0088] In the embodiment of the present application, the database access condition is set in advance in the middleware module, and the middleware module sends the operation request to the second ORM framework only when the database access condition is met. In this case, the middleware module can well overall plan the access of the entire database, meet all business needs, and support higher, special, and customized management and control configurations.

[0089] Step 204: The second ORM framework parses the operation request to obtain a SQL statement.

[0090] The SQL statement is used to operate data in the database. For example, the SQL statement can be a DML (Data Manipulation Language) statement, and specifically, the SQL statement can be used to add, delete, update, and find data in the database.

[0091] Since the operation request is generated by the first ORM framework according to the object-oriented business statement, the operation request includes object-oriented operation information. In this case, the second ORM framework in the ORM execution engine can parse the object-oriented operation request into a SQL statement, that is, parse the object-oriented operation request into a SQL statement that can be recognized by the database, to realize access to data in the database.

[0092] In this case, the second ORM framework can obtain a SQL statement that can be recognized by the database, and then interact with the database, so that the technical personnel do not need to write complex SQL statements, which provides convenience for the technical personnel, thereby improving the development efficiency. Moreover, in the embodiment of the present application, the application system does not need to directly communicate with the database, so it is not necessary to configure the account and password of the database in the application system, thereby ensuring the security of the database.

[0093] The second ORM framework parses the operation request to obtain the operation of the SQL statement, which is similar to the operation of the SQL statement obtained by parsing the operation request by a certain device in the related art, and the present application does not elaborate on this.

[0094] Step 205: The second ORM framework executes the SQL statement to access the data in the database to obtain the execution result of the SQL statement.

[0095] In the embodiment of the present application, the interface for communicating with the database is provided in the second ORM framework, so that the second ORM framework can access the database through the interface.

[0096] In this case, the second ORM framework executes the SQL statement, that is, interacts with the database through the interface provided in the second ORM framework, that is, operates on the object to be accessed in the database by the operation request, thereby obtaining the execution result, which is the request result of the operation request.

[0097] Further, after obtaining the execution result of the SQL statement, the second ORM framework can return the execution result of the SQL statement as the request result of the operation request to the application system to respond to the operation request sent by the application system.

[0098] For example, Figure 4 The interaction between the application system and the ORM execution engine is shown in the schematic diagram. Referring to Figure 4 , Figure 4 The application system 401 and the ORM execution engine 402 are included in the schematic diagram. The application system 401 sends the operation request to the ORM execution engine 402. The second ORM framework in the ORM execution engine 402 executes the SQL statement obtained by parsing the operation request to obtain the execution result, and then sends the execution result of the SQL statement as the request result of the operation request to the application system 401.

[0099] Optionally, the ORM execution engine can further include a cache module. In this case, after obtaining the operation request, the second ORM framework can directly execute the above steps 204-205 to obtain the request result of the operation request in the case that the operation type in the operation request is other than the query type. In the case that the operation type in the operation request is the query type, the above steps 204-205 can not be executed first, but it can be queried first whether the cache module has the data to be queried by the operation request.

[0100] The cache module is in communication connection with the ORM execution engine, and the cache module stores a plurality of key-value pairs. Each key-value pair in the plurality of key-value pairs stores the request result of an operation request with the operation type being the query type. The key value in each key-value pair in the plurality of key-value pairs is a hash value obtained by performing a hash operation on an operation request with the operation type being the query type, and the value value in each key-value pair in the plurality of key-value pairs is the request result of the operation request with the operation type being the query type. That is, for any key-value pair stored in the cache module, the key value in the key-value pair is a hash value of an operation request with the operation type being the query type, and the value value in the key-value pair is the request result of the operation request, that is, the data queried from the database by the operation request. For example, the cache module can be a key-value storage system, for example, the cache module can be a redis (Remote DIctionary Server, data structure server) cache system.

[0101] Specifically, after obtaining the operation request, in the case that the operation type in the operation request is the query type, the second ORM framework performs a hash operation on the operation request to obtain a hash value, queries the cache module for a key value identical to the hash value, and determines the value value in the key-value pair in which the key value identical to the hash value in the cache module as the request result of the operation request if the key value identical to the hash value is queried from the cache module. If the key value identical to the hash value is not queried from the cache module, the above steps 204-205 are executed, that is, the operation request is parsed to obtain the SQL statement, the SQL statement is executed to access the data in the database, and the execution result of the SQL statement is obtained as the request result of the operation request. In this case, a target key-value pair can also be generated and stored in the cache module.

[0102] The key value in the target key-value pair is the hash value of the operation request. The value value in the target key-value pair is the execution result of the SQL statement, that is, the request result of the operation request, that is, the data queried from the database after executing the SQL statement.

[0103] If the key value identical to the hash value is queried from the cache module, it indicates that the request result of the operation request exists in the cache module, that is, the data to be queried by the application system exists. The value in the key-value pair where the key value identical to the hash value is located in the cache module can be determined as the request result of the operation request, and further, the request result of the operation request can be returned to the application system.

[0104] If the key value identical to the hash value is not queried from the cache module, it indicates that the request result of the operation request does not exist in the cache module, that is, the data to be queried by the application system does not exist. The second ORM framework can parse the operation request to obtain the SQL statement, execute the SQL statement to access the data in the database, obtain the execution result of the SQL statement as the request result of the operation request, and then generate the target key-value pair and store the target key-value pair to the cache module. At this time, the request result of the operation request exists in the cache module. Further, the second ORM framework can return the request result of the operation request to the application system.

[0105] In this way, in the case that the application system needs to frequently and massively query data, the access pressure of the database can be reduced through the cache module. Moreover, the user of the application system will not perceive the existence of the cache module when accessing the database. In addition, since the speed of the ORM execution engine accessing the cache module is much higher than that of accessing the database, in the case that the data to be queried exists in the cache module, the data stored in the cache module can be directly returned to the application system, which can improve the data query efficiency, and for the application system, it is equivalent to improving the database access efficiency.

[0106] For example, Figure 5 is a flowchart of the process of accessing the database when the operation type in the operation request is the query type. Referring to Figure 5 , the process includes steps 501-506.

[0107] Step 501: The second ORM framework performs hash operation on the operation request to obtain a hash value.

[0108] Step 502: The second ORM framework queries the key value identical to the hash value from the cache module.

[0109] Step 503: If the key value identical to the hash value is queried from the cache module, the second ORM framework determines the value in the key-value pair where the key value is located as the request result of the operation request and returns the request result to the application system.

[0110] Step 504: If the second ORM framework does not find the key value same as the hash value from the cache module, the second ORM framework reads the data to be queried by the operation request from the database.

[0111] Specifically, the second ORM framework parses the operation request to obtain the SQL statement, executes the SQL statement to read the data to be queried by the operation request from the database, and obtains the execution result of the SQL statement. Then, the second ORM framework continues to execute step 505.

[0112] Step 505: The second ORM framework returns the execution result of the SQL statement to the application system as the request result of the operation request, and the second ORM framework executes step 506.

[0113] Step 506: The second ORM framework generates a target key-value pair and stores the target key-value pair in the cache module.

[0114] In some cases, the key-value pair in the cache module can be deleted in the embodiments of the present application, which will be described below:

[0115] Optionally, when a key-value pair is stored in the cache module, the key-value pair can be stored in association with the object identifier of the object to which the value in the key-value pair belongs. In this case, the value in the key-value pair stored in association with the object identifier of an object in the cache module is the data of the object.

[0116] For example, the association between the key-value pair and the object identifier in the cache module is shown in Table 1. As shown in Table 1, the object identifier of the object to which the value in each of the three key-value pairs in Table 1 belongs is Table1, so the three key-value pairs are stored in association with Table1.

[0117] Table 1

[0118] key value value value object identification 01011 1 Table 1 10010 2 Table 1 11100 3 Table 1 …… …… ……

[0119] The embodiments of the present application only take Table 1 as an example to illustrate the association between the key-value pair in the cache module and the object identifier, and Table 1 does not limit the embodiments of the present application.

[0120] In a first possible implementation, when the operation type in the operation request is an update type, the second ORM framework can delete all key-value pairs stored in association with the object identifier in the operation request in the cache module first, and then obtain the request result of the operation request through steps 204-205.

[0121] Since the operation type in the operation request is the update type, the purpose of this database access is to update the object identified by the object identifier in the operation request, so the data of the object identified by the object identifier in the operation request in the database will change, and the value in the key-value pair associated with the object identifier in the operation request in the cache module will not be the latest data of the object identified by the object identifier, and thus all key-value pairs associated with the object identifier in the operation request in the cache module are deleted.

[0122] In a second possible implementation, after the second ORM framework obtains the operation request, if the operation type in the operation request is the update type, the second ORM framework first obtains the request result of the operation request through steps 204-205, and then deletes all key-value pairs associated with the object identifier in the operation request in the cache module.

[0123] In a third possible implementation, for example, Figure 6 For the flowchart of accessing the database when the operation type in the operation request is the update type. Referring to Figure 6 , the flowchart includes steps 601-603.

[0124] Step 601: After the second ORM framework obtains the operation request, if the operation type in the operation request is the update type, the second ORM framework deletes all key-value pairs associated with the object identifier in the operation request in the cache module.

[0125] Step 602: The second ORM framework obtains the request result of the operation request through steps 204-205.

[0126] That is, the second ORM framework parses the operation request to obtain the SQL statement, executes the SQL statement to update the object to be accessed in the operation request in the database, and obtains the execution result of the SQL statement. The second ORM framework can determine the execution result of the SQL statement as the request result of the operation request and return the request result to the application system.

[0127] Step 603: The second ORM framework again deletes all key-value pairs associated with the object identifier in the operation request in the cache module.

[0128] Consider a case that if the second ORM framework deletes all the key-value pairs stored in the cache module in association with the object identifier in the operation request for the first time, another application system queries the data of the object identified by the object identifier in the operation request. After the other application system reads the data to be queried, it will store a key-value pair in the cache module again, which is stored in association with the object identifier in the operation request. However, at this time, the second ORM framework has not updated the object accessed by the operation request in the database. In this case, after updating the object accessed by the operation request in the database, the data of the object stored in the database is different from the value in the key-value pair cached in the cache module. Then, deleting all the key-value pairs stored in the cache module in association with the object identifier in the operation request again can ensure that there is no key-value pair stored in the cache module in association with the object identifier in the operation request after the data is updated, thereby ensuring the consistency of the data in the database and the data cached in the cache module.

[0129] It is worth noting that the database access method provided by the embodiments of the present application does not need to configure the account and password of the database in the application system, reduces the configuration complexity of the application system, protects the privacy data, and reduces the security risks of the data. In addition, since the application system does not need to directly connect the database, the TCP connection number of the database is no longer consumed, and the overall TCP connection number of the database is controllable and manageable.

[0130] It is worth noting that when there is a need to replace the database, the database can be changed directly in the ORM execution engine. For the application system, the application system does not perceive the change of the database, so the application system is not affected.

[0131] In the embodiments of the present application, the ORM execution engine includes a second ORM framework, the ORM execution engine is in communication connection with the application system, and the ORM execution engine is in communication connection with the database, and the application system includes a first ORM framework. The second ORM framework in the ORM execution engine acquires an operation request sent by the first ORM framework, the operation request is generated by the first ORM framework according to a business statement, that is, the application system sends an operation request to the ORM execution engine when needing to access the database. Then, the second ORM framework parses the operation request to obtain a SQL statement, which is a statement that can be recognized by the database. The second ORM framework executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect the database, so the password of the database does not need to be configured in the application system, and the ORM execution engine only needs to interact with the database to access the database, thereby ensuring the security of the database.

[0132] The following explains the processing procedure of the ORM execution engine when the application system sends one operation request to the ORM execution engine. The following explains the processing procedure of the ORM execution engine when the application system sends multiple operation requests to the ORM execution engine.

[0133] First, the concepts related to the transaction involved in the embodiments of the present application are explained.

[0134] A transaction is a collection of operations that constitute a single logical unit of work. A transaction can contain one or more operations that constitute a logical whole. The operations that constitute the logical whole are either all executed successfully or none of them is executed. That is, all the operations that constitute a transaction either all have an impact on the database or none of them has an impact on the database, so that the database can always maintain a consistent state regardless of whether the transaction is executed successfully or not.

[0135] A transaction has the ACID characteristics, which are: Atomicity: all the operations in a transaction are indivisible as an atom, and either all of them are successful or all of them fail. Consistency: the execution result of a transaction must make the database change from one consistent state to another consistent state. Isolation: concurrently executed transactions do not affect each other, and their impact on the database is the same as when they are executed in series. Durability: once a transaction is committed, its update to the database is persistent.

[0136] In some embodiments, there are two cases in which a transaction is used, and whether to automatically commit a transaction is determined by starting a transaction statement.

[0137] If the ORM execution engine does not receive a transaction start statement, it automatically commits the transaction, that is, executes a non-persistent transaction. Specifically, the ORM execution engine commits a SQL statement obtained by parsing an operation request after executing the SQL statement each time it receives an operation request. At this time, each obtained SQL statement is actually executed as a transaction. That is, in the above step 205, the second ORM framework instructs the database to commit the execution result of a SQL statement each time it obtains the execution result of the SQL statement. In this case, the automatic commit mode in the database access mode is used to implement the access to the data in the database.

[0138] If the ORM execution engine receives the start transaction statement, the transaction is not automatically committed, that is, a persistent transaction is executed. Specifically, when the ORM execution engine receives multiple operation requests, the ORM execution engine executes multiple SQL statements obtained by parsing the multiple operation requests as a whole as a transaction, and simultaneously commits or rolls back the execution results of the multiple SQL statements. In this case, the manual commit mode in the database access mode is used to implement access to data in the database. The following will explain this case in detail.

[0139] Figure 7 FIG. 1 is a flowchart of a database access method provided by an embodiment of the present application. Referring to FIG. 1, the method includes the following steps. Figure 7

[0140] Step 701: A first ORM framework sends a start transaction statement to an ORM execution engine.

[0141] The start transaction statement is used to instruct the ORM execution engine to start a transaction, so that multiple SQL statements obtained by parsing multiple operation requests sent subsequently by the first ORM framework are executed as a transaction, that is, the multiple SQL statements are simultaneously committed or rolled back.

[0142] When an application system determines that multiple database operations need to be executed in a transaction, a first ORM framework in the application system sends a start transaction statement to an ORM execution engine to instruct the ORM execution engine to create a transaction, so that multiple SQL statements obtained by parsing multiple operation requests sent subsequently by the first ORM framework are executed as a transaction.

[0143] Optionally, the application system and the ORM execution engine can communicate through a GRPC (Google Remote Procedure Call) protocol.

[0144] In this case, in the case where there is an ORM execution engine cluster including multiple ORM execution engines, if an application system first establishes a connection with an ORM execution engine in the ORM execution engine cluster, the communication connection between the application system and the ORM execution engine is not interrupted, and at this time, the application system can continuously send multiple operation requests to the ORM execution engine. In this way, it can be ensured that the multiple operation requests sent by the first ORM framework after the start transaction statement are sent to the same ORM execution engine, so that the ORM execution engine can execute multiple SQL statements obtained by parsing the multiple operation requests in the same transaction.

[0145] Step 702: A second ORM framework in the ORM execution engine creates a target transaction after obtaining the start transaction statement. ​

[0146] Optionally, the middleware module in the ORM execution engine can receive the start transaction statement sent by the first ORM framework, and then send the start transaction statement to the second ORM framework.

[0147] After obtaining the start transaction statement, the second ORM framework in the ORM execution engine can create a target transaction. Then, the second ORM framework can parse the multiple operation requests sent by the first ORM framework subsequently to obtain multiple SQL statements, and the multiple SQL statements can be regarded as SQL statements to be executed by the target transaction. The multiple SQL statements in the target transaction can be committed or rolled back at the same time. That is, the target transaction commit refers to simultaneously committing the execution results of the multiple SQL statements in the target transaction, and the target transaction rollback refers to simultaneously rolling back the execution results of the multiple SQL statements in the target transaction.

[0148] The operation of creating a target transaction by the second ORM framework is similar to the operation of creating a transaction by a device in the related art, and the embodiments of the present application do not elaborate on this.

[0149] Step 703: The first ORM framework sends multiple operation requests to the ORM execution engine.

[0150] Optionally, after sending the start transaction statement to the ORM execution engine, the first ORM framework can continuously send multiple operation requests to the ORM execution engine through the GRPC protocol, and each operation request in the multiple operation requests is used to request to operate the data in the database.

[0151] Step 704: The second ORM framework obtains an operation request, parses the obtained operation request to obtain a SQL statement belonging to the target transaction, and executes the newly obtained SQL statement belonging to the target transaction.

[0152] Optionally, the middleware module in the ORM execution engine can receive the operation request sent by the first ORM framework, and the middleware module can send the operation request to the second ORM framework under the condition that the database access condition is met.

[0153] The processing process of the second ORM framework in the ORM execution engine on the operation request can refer to the related operations in the embodiments of the present application described above, and the embodiments of the present application do not elaborate on this. Figure 2 The processing process of the second ORM framework in the ORM execution engine on the operation request can refer to the related operations in the embodiments of the present application described above, and the embodiments of the present application do not elaborate on this.

[0154] Specifically, the second ORM framework parses each operation request as it is obtained, obtains the SQL statements belonging to the target transaction, executes the newly obtained SQL statements belonging to the target transaction, and obtains the execution results. In this case, after the first ORM framework sends the plurality of operation requests to the ORM execution engine, the second ORM framework executes the SQL statements parsed from each of the plurality of operation requests, obtains the execution results of the plurality of SQL statements in the target transaction, and returns the execution result of each SQL statement as the request result of the corresponding operation request to the application system. Moreover, in this case, the second ORM framework does not instruct the database to commit the execution result of each SQL statement after obtaining the execution result of the SQL statement.

[0155] For example, Figure 8 An interaction diagram between the application system and the ORM execution engine is shown in FIG. 8. Referring to FIG. 8, Figure 8 , Figure 8 The application system 801 sends a plurality of operation requests to the ORM execution engine 802 after sending a start transaction statement to the ORM execution engine 802. The second ORM framework in the ORM execution engine 802 executes the SQL statements belonging to the target transaction parsed from each operation request as it is obtained, obtains the execution result of the SQL statement, and then sends the execution result of the SQL statement as the request result of the operation request to the application system 801, thereby sending the request result of each operation request in the plurality of operation requests to the application system 801.

[0156] Step 705: The first ORM framework sends a commit statement or a rollback statement to the ORM execution engine.

[0157] The commit statement is used to instruct to commit the target transaction, i.e., to instruct the database to commit the execution results of all the SQL statements in the target transaction. The rollback statement is used to instruct to rollback the target transaction, i.e., to instruct the database to rollback the execution results of all the SQL statements in the target transaction.

[0158] Step 706: If the commit statement is obtained, the second ORM framework instructs the database to commit the execution results of all the SQL statements in the target transaction.

[0159] Optionally, the middleware module in the ORM execution engine can receive the commit statement sent by the first ORM framework, and then send the commit statement to the second ORM framework.

[0160] In some embodiments, the operation on the data in the database is not substantially completed until the execution results of all the SQL statements in the target transaction are submitted, and the second ORM framework executing these SQL statements appears to the database as the database recording operation information of multiple operations on the object in the database. Only when the database receives the submission indication, the database submits the execution results of all the SQL statements in the target transaction, that is, truly implements the operation on the data in the database, and simultaneously performs multiple operations on the database.

[0161] Step 707: If the second ORM framework obtains the rollback statement, the second ORM framework instructs the database to roll back the execution results of all the SQL statements in the target transaction.

[0162] Optionally, the middleware module in the ORM execution engine can receive the rollback statement sent by the first ORM framework, and then send the rollback statement to the second ORM framework.

[0163] In this case, the database rolls back the execution results of all the SQL statements in the target transaction, that is, cancels the operations on the data in the database by all the SQL statements in the target transaction. In some embodiments, that is, deleting the operation information of multiple operations on the object in the database recorded by the database.

[0164] The following illustrates the beneficial effects of multiple accesses to the data in the database in one transaction.

[0165] Suppose a user purchases a commodity in an application system, and needs to pay when purchasing the commodity, and order information is generated after the purchase. At this time, the operation of reducing the balance of the user's account and the operation of adding an order information to the order list of the user need to be performed.

[0166] If the two operations are not performed in one transaction, the application system first sends an operation request for modifying the balance to the ORM execution engine, the ORM execution engine parses the operation request to obtain a SQL statement for modifying the balance, and then executes the SQL statement and submits the execution result to complete the modification of the balance of the user's account. Then the application system sends an operation request for adding order information to the ORM execution engine, and the ORM execution engine parses the operation request to obtain a SQL statement for adding order information. However, a network failure occurs when the ORM execution engine executes the SQL statement, so the operation of adding an order information to the order list of the user cannot be completed. In this case, the user can query the reduction of the balance of the account, but cannot query the order information of the purchased commodity.

[0167] If the two operations are executed in a transaction, the application system sends a start transaction statement to the ORM execution engine first, and then the ORM execution engine creates a target transaction. The application system sends a request for modifying the balance and a request for adding order information to the ORM execution engine, and the ORM execution engine parses the request for modifying the balance to obtain a SQL statement for modifying the balance, executes the SQL statement, and does not commit the execution result. Then, the ORM execution engine parses the request for adding order information to obtain a SQL statement for adding order information, executes the SQL statement, and does not commit the execution result. In some embodiments, the application system sends a commit statement to the ORM execution engine, and the ORM execution engine instructs the database to commit the execution results of the two SQL statements in the target transaction, so as to truly realize the modification of the user account balance and the addition of order information in the order list. At this time, the user can query that the account balance is reduced and the order list has order information of purchasing goods. In other embodiments, even if a network failure occurs, the ORM execution engine does not instruct the database to commit the execution results of the two SQL statements in the target transaction before receiving the commit statement, so that the data of the database does not change. At this time, the user can query that the balance of the account is not reduced, and the order list does not have order information. In this way, the multiple operations are executed in a transaction, so as to ensure the consistency of the multiple operations when executed.

[0168] In the embodiments of the present application, the first ORM framework sends a start transaction statement to the ORM execution engine to instruct the second ORM framework to create a target transaction, so that multiple SQL statements parsed from multiple operation requests sent by the first ORM framework subsequently can be executed in the target transaction. Then, the first ORM framework sends a commit statement or a rollback statement to the ORM execution engine, so that the second ORM framework instructs the database to commit or rollback the execution results of all SQL statements in the target transaction at the same time. In this way, multiple operations with association can be committed in the database at the same time, the consistency of the multiple operations when executed is ensured, and the consistency of the database is ensured.

[0169] The database access system provided by the embodiments of the present application is explained and described below.

[0170] Figure 9 is a structural schematic diagram of a database access system provided by the embodiments of the present application. Referring to Figure 9 The database access system includes multiple application systems 101 and an ORM execution engine cluster, which can be composed of multiple ORM execution engines 102.

[0171] Any one of the plurality of application systems 101 can communicate with any one of the plurality of ORM execution engines 102.

[0172] The application system 101 is explained as follows:

[0173] Each of the plurality of application systems 101 comprises a first ORM framework. The first ORM framework can generate an operation request according to a business statement, and send the operation request to the ORM execution engine 102.

[0174] The operation request is used to request an operation on data in the database 103. The first ORM framework sends the operation request to the ORM execution engine 102, which is sending the operation request to any one of the plurality of ORM execution engines 102.

[0175] The first ORM framework generates the operation request according to the business statement, and the related content of sending the operation request to the ORM execution engine 102 has been described in the Figure 2 The steps 201 and 202 in the embodiments are described in detail, and the present application embodiments will not be repeated.

[0176] In this case, the application system 101 only needs to generate an operation request according to the business statement written by the technical personnel using the object-oriented language, and send the operation request to the ORM execution engine 102. Without the need to parse the business statement written by the technical personnel using the object-oriented language. In this way, the business pressure of the application system 101 can be reduced, and the performance of the application system 101 can be improved.

[0177] The ORM execution engine 102 is explained as follows:

[0178] Each of the plurality of ORM execution engines 102 in the ORM execution engine cluster is in communication connection with the database 103. In some embodiments, the plurality of ORM execution engines 102 in the ORM execution engine cluster can communicate with each other to realize data sharing.

[0179] Each of the plurality of ORM execution engines 102 in the ORM execution engine cluster comprises a second ORM framework. The second ORM framework can execute the above-mentioned Figure 2 The steps 203-205 in the embodiments, that is, obtaining the operation request sent by the first ORM framework, parsing the operation request to obtain a SQL statement, executing the SQL statement to access data in the database 103, and obtaining an execution result of the SQL statement.

[0180] In this case, the ORM execution engine 102 acts as a bridge between the application system 101 and the database 103, so that the application system 101 does not need to be directly connected to the database 103, but is connected to the database 103 by the ORM execution engine 102 to realize access to the database 103. Therefore, it is not necessary to configure the account password of the database 103 in the application system 101, and the security of the database 103 is improved.

[0181] Optionally, the application system 101 and the ORM execution engine 102 can communicate through the GRPC protocol. In this way, it can be ensured that the plurality of operation requests sent by the first ORM framework in an application system 101 are sent to the same ORM execution engine 102, so that the SQL statements parsed from the plurality of operation requests can be executed in one transaction. The above Figure 7 The embodiments explain the process of executing a plurality of SQL statements parsed from a plurality of operation requests in one transaction, and the embodiments of the present application will not be repeated.

[0182] In one possible case, referring to Figure 10 The database access system can further include a middleware module 1001, which is in communication connection with the application system 101, that is, the middleware module 1001 can directly communicate with the first ORM framework.

[0183] The middleware module 1001 can send the operation request to the second ORM framework 1002 after receiving the operation request sent by the application system 101, if the database access condition is met.

[0184] For example, Figure 11 A schematic diagram of the middleware module 1001 is shown. Referring to Figure 11 , Figure 11 The middleware module 1001, the second ORM framework 1002, and the application system 101 are included. For example, the following database access conditions can be set in the middleware module 1001:

[0185] The access frequency of the database 103 is less than a first threshold (flow control).

[0186] The application system 101 has access permission to the object to be accessed by the operation request (table permission control).

[0187] The application system 101 has access permission to the database 103 (account system authentication).

[0188] The operation type in the operation request is an operation type allowed by the database 103 to the object to be accessed by the operation request (ORM syntax control).

[0189] The middleware module 1001 first judges whether the operation request meets the set database access condition after receiving the operation request, and only sends the operation request to the second ORM framework 1002 when the operation request meets the database access condition.

[0190] The related content of the database access condition has been described in the description of the first aspect of the application. Figure 2 The step 203 in the embodiment is explained and described, and the present application will not be repeated.

[0191] In this case, by setting the database access condition in the middleware module 1001, the ORM execution engine 102 can well overall manage the access of the entire database 103, while meeting all business needs and supporting higher-level, special, and customized management and control configurations.

[0192] In one possible case, referring to Figure 12 The database access system can further include a cache module 1201 in communication connection with the ORM execution engine 102. The cache module 1201 stores a plurality of key-value pairs, each of which stores a request result of an operation request of a query type. That is, the key value in each key-value pair in the plurality of key-value pairs is a hash value obtained by performing a hash operation on an operation request of a query type, and the value value in each key-value pair in the plurality of key-value pairs is a request result of the operation request of the query type. That is, for any key-value pair stored in the cache module 1201, the key value in the key-value pair is a hash value of an operation request of a query type, and the value value in the key-value pair is a request result of the operation request, that is, data queried from the database 103 by the operation request.

[0193] In this case, when the operation type in the operation request is other than the query type, the second ORM framework 1002 can directly execute the above steps 204-205 to obtain the request result of the operation request.

[0194] In the case that the operation type in the operation request is a query type, the second ORM framework can first perform a hash operation on the operation request to obtain a hash value; and query a key value same as the hash value from the cache module 1201. If the key value same as the hash value is queried from the cache module 1201, the value in the key-value pair where the key value same as the hash value is located in the cache module 1201 is determined as the request result of the operation request. If the key value same as the hash value is not queried from the cache module 1201, the second ORM framework performs the above steps 204-205, that is, the operation request is parsed to obtain the SQL statement, the SQL statement is executed to access the data in the database, and the execution result of the SQL statement is obtained as the request result of the operation request. In this case, the target key-value pair can also be generated and stored in the cache module 1201.

[0195] In the case that the operation type in the operation request is an update type, the second ORM framework can delete all key-value pairs stored in the cache module 1201 in association with the object identifier in the operation request.

[0196] The interaction process between the ORM execution engine 102 and the cache module 1101 has been explained in the above Figure 2 The step 205 in the embodiment has been explained and described above, and the present embodiment will not be repeated.

[0197] In the case that the database access system includes the cache module 1201, if the application system 101 needs to frequently and massively query data, the access pressure of the database 103 can be reduced through the cache module 1201. Moreover, the user of the application system 101 will not perceive the existence of the cache module 1201 when accessing the database 103. In addition, since the speed of the ORM execution engine 102 accessing the cache module 1201 is much faster than that of accessing the database 103, in the case that the data to be queried exists in the cache module 1201, the data stored in the cache module 1201 is directly returned to the application system, which can improve the data query efficiency, and for the application system 101, it is equivalent to improving the database access efficiency.

[0198] It is worth noting that the application system 101 in the database access system provided by the embodiment of the present application does not need to be directly connected with the database 103, but accesses the database 103 through the ORM execution engine 102 arranged between the application system 101 and the database 103. Specifically, the application system 101 sends an operation request to the ORM execution engine 102 to request to access data in the database 103, and then the ORM execution engine 102 communicates with the database 103 to realize the access to the database 103. In this way, the account and password of the database 103 do not need to be configured in the application system 101, which reduces the configuration complexity of the application system 101, protects the privacy data, reduces the security risks of the data, and ensures the security of the database 103.

[0199] It is worth noting that, since the application system 101 does not need to be directly connected with the database 103, the TCP connection number of the database 103 is no longer consumed, and the overall TCP connection number of the database 103 is controllable and manageable. Meanwhile, since the application system 101 and the ORM execution engine 102 in the database access system provided by the embodiment of the present application communicate through the GRPC protocol, which is a high-efficiency multiplexing technology, the difficulty of connection pool management of the application system 101 is reduced.

[0200] In the embodiment of the present application, the application system includes a first ORM framework, the ORM execution engine includes a second ORM framework, and the ORM execution engine is in communication connection with the database. The first ORM framework generates an operation request according to a business statement, and sends the operation request to the ORM execution engine, that is, the application system sends an operation request to the ORM execution engine when needing to access the database. Then, the second ORM framework in the ORM execution engine receives the operation request, parses the operation request to obtain a SQL statement, and the SQL statement is a statement recognizable by the database. Then, the second ORM framework executes the SQL statement to access data in the database. In this way, the application system does not need to be directly connected with the database, and thus the password of the database does not need to be configured in the application system, but the ORM execution engine interacts with the database to realize the access to the database, thereby ensuring the security of the database.

[0201] Figure 13 A structural schematic diagram of a computer device provided by the embodiment of the present application is shown in FIG. 13. Figure 13 As shown in FIG. 13, the computer device 13 includes a processor 130, a memory 131, and a computer program 132 stored in the memory 131 and executable on the processor 130, and the processor 130 implements the steps executed by the ORM execution engine in the database access method in the above-mentioned embodiments when executing the computer program 132.

[0202] The computer device 13 can be a general-purpose computer device or a special-purpose computer device. In a specific implementation, the computer device 13 can be a network server. Those skilled in the art can understand that Figure 13 The computer device 13 is merely an example and does not limit the computer device 13, which can include more or fewer components than shown, or combine some components, or include different components, such as an input / output device, a network access device, and the like.

[0203] The processor 130 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, and the like. The general-purpose processor can be a microprocessor or any conventional processor.

[0204] The memory 131 can be an internal storage unit of the computer device 13, such as a hard disk or a memory of the computer device 13 in some embodiments. The memory 131 can also be an external storage device of the computer device 13, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like in other embodiments. Further, the memory 131 can include both the internal storage unit and the external storage device of the computer device 13. The memory 131 is used to store an operating system, an application program, a boot loader, data, and other programs, and the like. The memory 131 can also be used to temporarily store data that has been output or will be output.

[0205] The embodiments of the present application also provide a computer device, which comprises at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above method embodiments when executing the computer program.

[0206] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is executable by a processor to implement the steps in any of the above method embodiments.

[0207] The embodiments of the present application provide a computer program product, which, when running on a computer, causes the computer to execute the steps in the above-mentioned various method embodiments.

[0208] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the present application can implement all or part of the processes in the above-mentioned method embodiments by a computer program to instruct related hardware to complete, and the computer program can be stored in a computer readable storage medium. The computer program can implement the steps of the above-mentioned various method embodiments when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium at least includes any entity or device capable of carrying the computer program code to the photographing device / terminal equipment, recording medium, computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk and optical data storage device, etc. The computer readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, can be a non-transitory storage medium.

[0209] It should be understood that all or part of the steps of the above-mentioned embodiments can be realized by software, hardware, firmware or any combination thereof. When realized by software, it can be realized in the form of a computer program product in whole or in part. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-mentioned computer readable storage medium.

[0210] In the above-mentioned embodiments, the description of each embodiment has its own focus, and the parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.

[0211] Those skilled in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0212] In the embodiments provided by the present application, it should be understood that the disclosed apparatus / computer device and method can be implemented in other manners. For example, the embodiments of the apparatus / computer device described above are merely schematic; for example, the division of the modules or units can not be strict, and some modules or units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the display or discussion about the coupling or direct coupling or communication connection between the modules can be through some interfaces, and can also be indirect coupling or communication connection through some interfaces, or electrical, mechanical or other forms.

[0213] The units described as separated components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments.

[0214] The above-described embodiments are merely used to illustrate the technical solutions of the present application, but not limit the present application; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: the technical solutions recorded in the foregoing embodiments can still be modified, or some technical features can be replaced by equivalent replacements; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A database access system, characterized by The database access system comprises an application system and an ORM execution engine, the application system comprises a first ORM framework, the ORM execution engine comprises a second ORM framework, and the ORM execution engine is in communication connection with a database; The first ORM framework is configured to generate an operation request according to a business statement, and send the operation request to the ORM execution engine, where the operation request is used to request an operation on data in the database; The second ORM framework is configured to, after obtaining the operation request, parse the operation request to obtain a structured query language (SQL) statement, and execute the SQL statement to access the data in the database to obtain an execution result of the SQL statement.

2. The database access system of claim 1, wherein The first ORM framework is configured to send a start transaction statement to the ORM execution engine; The second ORM framework is configured to, after obtaining the start transaction statement, create a target transaction; The first ORM framework is configured to, after sending the start transaction statement to the ORM execution engine, send a plurality of operation requests to the ORM execution engine; The second ORM framework is configured to, after creating the target transaction, parse each operation request to obtain a SQL statement belonging to the target transaction, and execute the latest obtained SQL statement belonging to the target transaction, after obtaining each operation request; The first ORM framework is configured to send a commit statement or a rollback statement to the ORM execution engine; The second ORM framework is configured to, if the commit statement is obtained, instruct the database to commit execution results of all SQL statements in the target transaction; and if the rollback statement is obtained, instruct the database to roll back the execution results of all SQL statements in the target transaction. The application system and the ORM execution engine communicate through a remote procedure call (RPC) protocol.

3. The database access system of claim 1, wherein, The ORM execution engine further comprises a middleware module in communication connection with the application system; 4. The database access system of any one of claims 1 to 3, wherein, The middleware module is configured to, after receiving the operation request sent by the first ORM framework, send the operation request to the second ORM framework if a database access condition is met. The operation request carries an object identifier and an operation type, and the object identifier is used to identify an object to be accessed by the operation request; 5. The database access system of claim 4, wherein, The database access condition comprises at least one of the following conditions: The number of accesses to the database is less than a first number threshold; The number of accesses to the object to be accessed by the operation request is less than a second number threshold; The application system has an access right to the object to be accessed by the operation request; The application system has an access right to the database; The operation type in the operation request is an operation type allowed by the database on the object to be accessed by the operation request. The operation request carries an object identifier and an operation type, and the database access system further comprises a cache module; 6. The database access system of any one of claims 1 to 3, wherein, ​ The second ORM framework is configured to, in a case where the operation type in the operation request is a query type, perform a hash operation on the operation request to obtain a hash value. The same key value as the hash value is queried from the cache module. If the same key value as the hash value is queried from the cache module, a value in a key-value pair in which the key value is the same as the hash value in the cache module is determined as a request result of the operation request. If the same key value as the hash value is not queried from the cache module, the operation request is parsed to obtain the SQL statement, the SQL statement is executed to access data in the database, an execution result of the SQL statement is obtained as the request result of the operation request, a target key-value pair is generated, the key value in the target key-value pair is the hash value, and the value in the target key-value pair is the execution result of the SQL statement.

7. The database access system of claim 6, wherein, The cache module is configured to store key-value pairs in association with object identifiers of objects to which values in the key-value pairs belong. The second ORM framework is configured to, in a case where the operation type in the operation request is an update type, delete all key-value pairs stored in association with the object identifier in the operation request in the cache module.

8. A database access method, characterized by, The method is applied to an ORM execution engine, the ORM execution engine includes a second ORM framework, the ORM execution engine is in communication connection with an application system, the ORM execution engine is in communication connection with a database, the application system includes a first ORM framework, and the method includes the following steps: The second ORM framework obtains an operation request sent by the first ORM framework, the operation request is generated by the first ORM framework according to a business statement, and the operation request is used to request to perform an operation on data in the database. The second ORM framework parses the operation request to obtain a structured query language (SQL) statement. The second ORM framework executes the SQL statement to access data in the database to obtain an execution result of the SQL statement.

9. The method of claim 8, wherein, The ORM execution engine further includes a middleware module, and the middleware module is in communication connection with the application system. The second ORM framework obtains an operation request sent by the first ORM framework, and the operation request is generated by the first ORM framework according to a business statement. The middleware module receives the operation request sent by the first ORM framework, and sends the operation request to the second ORM framework in a case where a database access condition is met.

10. The method of claim 9, wherein, The operation request carries an object identifier and an operation type, and the object identifier is used to identify an object to be accessed by the operation request. The database access condition includes at least one of the following multiple conditions: An access frequency of the database is less than a first frequency threshold. An access frequency of the object to be accessed by the operation request is less than a second frequency threshold. The application system has an access right to the object to be accessed by the operation request. The application system has an access right to the database. The operation type in the operation request is an operation type allowed by the database to be performed on an object accessed by the operation request.

11. A computer device, comprising: The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program, when executed by the processor, implements the method according to any one of claims 8 to 10.

12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the method according to any one of claims 8 to 10.

Citation Information

Patent Citations

  • Platform for data services across disparate application frameworks

    US20060195476A1

  • Systems to remove object relational mappings from a software project

    US20190026090A1