CN117112538A - Database operation method, database operation device, computer equipment and storage medium - Google Patents

Database operation method, database operation device, computer equipment and storage medium Download PDF

Info

Publication number
CN117112538A
CN117112538A CN202311140175.8A CN202311140175A CN117112538A CN 117112538 A CN117112538 A CN 117112538A CN 202311140175 A CN202311140175 A CN 202311140175A CN 117112538 A CN117112538 A CN 117112538A
Authority
CN
China
Prior art keywords
target
database
type
target object
package
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311140175.8A
Other languages
Chinese (zh)
Inventor
孙卓辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongdian Jinxin Software Co Ltd
Original Assignee
Zhongdian Jinxin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongdian Jinxin Software Co Ltd filed Critical Zhongdian Jinxin Software Co Ltd
Priority to CN202311140175.8A priority Critical patent/CN117112538A/en
Publication of CN117112538A publication Critical patent/CN117112538A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2452Query translation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application relates to a database operating method, apparatus, computer device, storage medium and computer program product. The method comprises the following steps: writing a target module in a first type filing package through a target middleware to obtain a target object; defining a call interface in a first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices; and carrying out target operation on each target database device by calling the interface and the target object. By adopting the method, the database equipment layers can be layered from the angle of the data packet to obtain a plurality of independent layers, and the operation on the database equipment is converted into the object-oriented operation through a plurality of independent objects, so that the unified operation on single database equipment or a plurality of database equipment is realized, the adaptation on different types of database equipment is realized, and the universality is improved.

Description

Database operation method, database operation device, computer equipment and storage medium
Technical Field
The present application relates to the field of database technologies, and in particular, to a database operation method, apparatus, computer device, storage medium, and computer program product.
Background
Database dialect (Database Language) refers to a set of grammatical rules and data structures for representing database structures and properties, which are one of the important concepts in database theory, for constructing various types of databases, including relational databases and non-relational databases; when developing an application program, a developer uses multiple types of databases, so how to ensure unified operation on multiple types of databases is a problem to be solved.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a database operating method, apparatus, computer device, computer-readable storage medium, and computer program product that enable versatility of various types of database devices.
In a first aspect, the present application provides a database operating method. The method comprises the following steps:
writing a target module in a first type filing package through a target middleware to obtain a target object;
defining a call interface in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices;
and carrying out target operation on each target database device through the calling interface and the target object.
In one embodiment, the performing, through the call interface and the target object, a target operation on each target database device includes:
determining a second type filing package through the calling interface;
if the primary structured query language statement in the second type filing package is determined to support conversion across database equipment, converting the primary structured query language statement based on the target object to obtain a target structured query language statement;
and performing target operation on each target database device based on the target structured query language statement.
In one embodiment, the converting the native structured query language sentence based on the target object to obtain the target structured query language sentence includes:
determining a target database type of the target object based on the database connection information of the target object;
and converting each field name of the target object into a grammar structure matched with the target database type through a dialect component and the native structured query language sentence to obtain the target structured query language sentence of the target database type.
In one embodiment, the performing, through the call interface and the target object, a target operation on each target database device includes:
if the primary structured query language statement in the second type filing package does not support the conversion of the cross-database equipment, determining a target database type of the target object based on the database connection information of the target object, and determining the second type filing package matched with the target database type;
and carrying out target operation on each target database device through the second type filing package matched with the target database type.
In one embodiment, the method further comprises:
and under the condition that the target object is determined to be the target operation aiming at the target database equipment, performing the target operation on the database equipment by using the target object through the function contained in the target middleware.
In one embodiment, the target operation includes one or more of an add operation, a query operation, a delete operation, and a modify operation.
In a second aspect, the application further provides a database operating device. The device comprises:
The writing module is used for writing in the target module in the first type filing package through the target middleware to obtain a target object;
an interface definition module for defining a call interface in the first type archive package if it is determined that the target object is a target operation for a plurality of database devices;
and the calling module is used for carrying out target operation on each target database device through the calling interface and the target object.
In one embodiment, the calling module is specifically configured to:
determining a second type filing package through the calling interface;
if the primary structured query language statement in the second type filing package is determined to support conversion across database equipment, converting the primary structured query language statement based on the target object to obtain a target structured query language statement;
and performing target operation on each target database device based on the target structured query language statement.
In one embodiment, the calling module is further specifically configured to:
determining a target database type of the target object based on the database connection information of the target object;
And converting each field name of the target object into a grammar structure matched with the target database type through a dialect component and the native structured query language sentence to obtain the target structured query language sentence of the target database type.
In one embodiment, the calling module is specifically configured to:
if the primary structured query language statement in the second type filing package does not support the conversion of the cross-database equipment, determining a target database type of the target object based on the database connection information of the target object, and determining the second type filing package matched with the target database type;
and carrying out target operation on each target database device through the second type filing package matched with the target database type.
In one embodiment, the apparatus further comprises:
and the function operation module is used for performing target operation on the database equipment by using the target object through the function contained in the target middleware under the condition that the target object is determined to be the target operation aiming at the target database equipment.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of:
Writing a target module in a first type filing package through a target middleware to obtain a target object;
defining a call interface in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices;
and carrying out target operation on each target database device through the calling interface and the target object.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
writing a target module in a first type filing package through a target middleware to obtain a target object;
defining a call interface in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices;
and carrying out target operation on each target database device through the calling interface and the target object.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of:
Writing a target module in a first type filing package through a target middleware to obtain a target object;
defining a call interface in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices;
and carrying out target operation on each target database device through the calling interface and the target object.
The database operating method, apparatus, computer device, storage medium and computer program product described above, the method comprising: writing a target module in a first type filing package through a target middleware to obtain a target object; defining a call interface in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices; and carrying out target operation on each target database device through the calling interface and the target object. By adopting the method, the database equipment layers can be layered from the angle of the data packet to obtain a plurality of independent layers, and the operation on the database equipment is converted into the object-oriented operation through a plurality of independent objects, so that the unified operation on single database equipment or a plurality of database equipment is realized, the adaptation on different types of database equipment is realized, and the universality is improved.
Drawings
FIG. 1 is a flow diagram of a method of database operation in one embodiment;
FIG. 2 is a flow chart of a step of converting to obtain a target sql in one embodiment;
FIG. 3 is a flow diagram of the steps of determining the type of database device in one embodiment;
FIG. 4 is a flow chart illustrating the steps of performing a target operation in one embodiment;
FIG. 5 is a schematic diagram of an example of operation in one embodiment;
FIG. 6 is a flow chart of a method of database operation in another embodiment;
FIG. 7 is a block diagram of the architecture of a database operating apparatus in one embodiment;
fig. 8 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
In one embodiment, a database operation method is provided, where the method is applied to a database client to illustrate, it is understood that a database system may include a plurality of database clients and a database server corresponding to the database clients, that is, a database device; the database server is used for storing data, and the database client side and the database server can communicate through a network. The database client may be, but not limited to, various personal computers, notebook computers, smartphones, tablet computers, etc., and the database server may be implemented by a stand-alone server or a server cluster composed of a plurality of servers. In this embodiment, as shown in fig. 1, the database operation method is exemplified by application to a database client, and includes the following steps:
And 102, compiling a target module in the first type filing package through the target middleware to obtain a target object.
The target Middleware may be Middleware (Middleware) that provides a connection between system software and application software, and is used for implementing data interaction between various components of the software, and the Middleware may be an ORM Middleware of a third party application, for example, mybatis, or beetlsql. The first type of archive package may be a service type archive package, for example, a service jar package, the target module may be a running module in the first type of archive package, for example, a model, and the target object may be an object obtained by writing java, for example, a java object, which carries multiple types of instructions of a user account to a database device.
Specifically, the database client can write in a model module in the service jar package through the ORM middleware of the third party application to obtain the target object. In one example, the database client may write in a model module in a service jar package based on the ORM middleware of the third party application to obtain a java object.
In step 104, a call interface is defined in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices.
The target operation may be an instruction for processing the database device, for example, may include an instruction for adding or deleting data in the database device, an instruction for modifying data in the database device, or an instruction for querying data in the database device, for example, an instruction for querying data in the database device; processing the plurality of database devices by one instruction may be performed for the plurality of database devices; the call interface may be a DAO interface for implementing the implementation of the target syntax, for example, mysql syntax. In one example, the target operation may be a single table dql operation, or may also be an operation directed to multiple tables dql.
Specifically, the database client determines the database device operated by the target object, and if the database client determines that the target object is an operation for a plurality of database devices, the specific type of the operation is determined, and a call interface for implementing mysql grammar is defined in the first type archive package, for example, the call interface may be a DAO interface, and the DAO interface may be a data access object DAO (Data Access Object).
And 106, performing target operation on each target database device by calling the interface and the target object.
Specifically, the database client may implement, by operating on the target object, a target operation on one target database device, or target operations on multiple target database devices, so as to obtain one target database device or multiple target database devices after performing the target operation processing.
In the database operation method, the target middleware is used for writing the target module in the first type filing package, so that the target object is obtained. In the event that the target object is determined to be a target operation for a plurality of database devices, a call interface is defined in a first type archive package. And carrying out target operation on each target database device by calling the interface and the target object. By adopting the method, the database equipment layers can be layered from the angle of the data packet to obtain a plurality of independent layers, and the operation on the database equipment is converted into the object-oriented operation through a plurality of independent objects, so that the unified operation on single database equipment or a plurality of database equipment is realized, the adaptation on different types of database equipment is realized, and the universality is improved.
In one embodiment, as shown in fig. 2, the specific processing procedure of the step of performing the target operation on each target database device by calling the interface and the target object includes:
step 202, determining a second type of archive package by calling an interface.
The call interface may be an interface for implementing the mysql syntax, and the second type archive package may be a Jar package in a Mapper type, and the second type archive package may also be a layer for implementing the mysql syntax.
In particular, the database client may determine a second type of archive package for implementing mysql syntax, i.e. a Jar package of the Mapper type determining the Mapper layer, through a call interface defined in the first type archive package.
Step 204, if it is determined that the native structured query language sentence in the second type archive package supports the conversion across database devices, converting the native structured query language sentence based on the target object to obtain the target structured query language sentence.
Wherein, the native SQL (Structured Query Language ) can be generated by the application program under running condition; the native sql (Native SQL) refers to a language for data management and querying using a relational database management system (RDBMS). The cross-database device can be used for processing across a plurality of different database devices, and can also be used for converting across a plurality of types of database devices; converting the native sql may be converting the native sql to a target dialect type, and the target sql may be an sql statement that matches the type of the respective database device.
In particular, the database client may determine whether the native sql in the second type of archive package supports conversion across multiple database devices or whether the native sql in the second type of archive package supports conversion across multiple types of database devices. If the database client determines that the native sql in the second-type archive package supports conversion across multiple types of database devices, the database client may perform conversion processing on the native sql in the second-type archive package based on the target object and the type of the target database device to obtain an sql matched with the type of the target database device, that is, a target structured query language statement.
And 206, performing target operation on each target database device based on the target structured query language statement.
Specifically, the database client may perform target operations on multiple types of database devices based on the target sql after performing the conversion process, so as to implement target operation processing on multiple types of database devices, and obtain target database devices of each type after performing the target operation processing.
In the embodiment, under the condition that the fact that the original sql in the filing package supports conversion across multiple types of database equipment is determined, the database equipment is processed based on the obtained target sql, so that adaptation with the multiple types of database equipment is guaranteed, and universality is guaranteed.
In one embodiment, as shown in fig. 3, the specific processing procedure of the step of converting the native structured query language sentence based on the target object to obtain the target structured query language sentence includes:
step 302, determining a target database type of the target object based on the database connection information of the target object.
The database connection information may be data source connection information, where the data source connection information is connection information for characterizing a database type of a target database device to be operated by the target object; in one example, the data source connection information of mysql may be: jdbc: mysql:// IP: port, etc.
Specifically, the database client may obtain the data source connection information of the target database device corresponding to the target object, and based on the target database type of the target object through the dialect component.
Step 304, converting each field name of the target object into a grammar structure matched with the target database type through the dialect component and the native structured query language sentence, and obtaining the target structured query language sentence of the target database type.
Wherein the target object may include various fields.
Specifically, the database client can realize conversion of the structured query language statement through the dialect component, and the database client can convert each field name of the target object for describing the target operation into a grammar structure matched with the type of the target database determined based on the database connection information through the dialect component and the native sql, so that the target structured query language statement is obtained.
In the embodiment, the transformation component interprets variable definitions of java classes and converts field names of the java class definitions into target database types based on database connection information, so that the transformation from definition of java objects to different database types is realized, and the automatic adaptation with different types of database equipment is ensured.
In one embodiment, as shown in fig. 4, the specific processing procedure of the step of performing the target operation on each target database device by calling the interface and the target object includes:
if it is determined that the native structured query language statements in the second type archive package do not support cross-database device conversion, then the target database type of the target object is determined based on the database connection information of the target object, and a second type archive package matching the target database type is determined, step 402.
Specifically, when the database client determines that the native sql in the second type filing package does not support conversion across multiple database devices, the database client may acquire database connection information corresponding to a target database device to be used by the target object, determine a target database type of the target database device to be used by the target object based on the database connection information, and determine the second type filing package matched with the target database type. In one example, the second type archive package may be a mapper layer jar package.
Step 404, performing target operation on each target database device through a second type filing package matched with the target database type.
Specifically, the database client can implement the target operation on the database devices of each type through the second type filing package matched with the target database type, that is to say, the database client can implement the target operation on the database devices of each type through the mapper layer jar package matched with the target database type.
In the embodiment, the transformation component interprets variable definitions of java classes and converts field names of the java class definitions into target database types based on database connection information, so that the transformation from definition of java objects to different database types is realized, and the automatic adaptation with different types of database equipment is ensured.
In one embodiment, the database operating method further comprises:
and in the case that the target object is determined to be the target operation for the target database device, performing the target operation on the database device by using the target object through the function contained in the target middleware.
The function contained in the target middleware may be a function built in the middleware, for example, may be an operation function preset in the middleware, and the middleware may be an ORM middleware of a third party.
Specifically, the database client may determine that the target object corresponding to the target operation is an operation directed to a single database device or an operation of multiple database devices. In the case that the database client determines that the current target object is a target operation for a single target database device, the database client can operate the target operation through a built-in function in the middleware of the third party, so as to realize the target operation on the target database device. That is, the database client may convert the operation of the Provider in mybatis to the DDL operation, or the DML operation, into the operation of the target object, so as to implement the image operation (CRUD operation) to the target database device, and the built-in function in the third party middleware may be the Provider function in mybatis.
In this embodiment, CRUD operation on database devices is implemented through Java objects, conversion to different types of database devices is implemented, and the method is adapted to multiple types of database devices, so that development workload of developers is reduced, and development efficiency and development quality of programs are improved.
In one embodiment, the target operations include one or more of an add operation, a query operation, a delete operation, and a modify operation.
Specifically, the target operation may be a DDL (Data Definition Language ) operation, or a DQL (Data Query Language, data query language) operation, and the target operation may be a DDL operation or a DQL operation for a single table (single database device), or a DDL operation or a DQL operation for multiple tables (multiple database devices), for example, a CRUD operation (Create, read, update, delete), or an add operation, a delete operation, a query operation, or a modify operation. The DML Service operations may include all database DML operations, and DDL Service may be operations for creating tables (which may include master tables/sub-tables), indexes, etc., meta Data Service (metadata services) adapted to query database structures, table (which may include master tables/sub-tables) structures, column attributes, etc.
In this embodiment, in the implementation of the database persistence layer implemented in the DAO package, multiple implementation forms are supported, and ddl operations or dql operations can be converted into operations aimed at the target object, so as to ensure unified processing of multiple types of database devices, ensure universality of target object execution target operations, and improve processing efficiency of the database devices.
The following describes in detail, in connection with a specific embodiment, a specific implementation procedure of the database operation method described above:
in the related art, how to implement the operation of multiple database devices of multiple types without modifying the code based on the sql statement implementation. The database operation method provided by the embodiment can be used forBased onThe mysql grammar writes the sql script, and through the dialect component, the mysql grammar is used as an intermediate language to convert to grammar types corresponding to different databases, and the specific conversion process can comprise: and acquiring the data source connection information, and determining the target database type of the transferred data source based on the data source connection information.
When the sql is sent to the database equipment, intercepting a sending request containing the sql, analyzing the sending request to obtain the sql, converting the sql into an sql grammar corresponding to the database type through a dialect component to obtain a target sql, and then sending a message containing the target sql to the database. Therefore, a developer can write the sql statement only based on the mysql grammar, when the sql statement runs, the conversion of the sql script to the grammar of various database types can be realized through the dialect component, the conversion of the grammar difference of different databases is realized through the dialect component, the conversion to the grammar of different databases is dynamically realized, the developer does not need to know the difference of different databases, and the development efficiency of the developer is ensured.
As shown in FIG. 5, each running instance includes a plug-in JAR package, an oracle mapper layer JAR package, a mysql mapper layer JAR package, and a business implementation JAR package; the running example can also perform data transmission with plug-in jar packages and data transmission with oracle mapper layer jar packages through an sql conversion tool in a dql tool, and the sql conversion tool can convert an sql template through a specified dialect to generate DAOIMP, namely convert the sql template with a coding mode to generate jar packages or class.
The service implementation jar package may include a model module, a serial module serial lpl module, and an IXxxDAO module, where the model module is a database object definition, the serial module is a service logic definition, the serial lpl module may be a service logic implementation, and the IXxxDAO module may be an interface definition, to implement the definition of the interface. The oracle mapper layer jar package is realized through daolmpl persistence, and the mysql mapper layer jar package is realized through XxxDAOlmpl. The oracle mapper layer JAR package and the mysql mapper layer JAR package are implemented by virtue of plug-in JAR package persistence, and plug-in JAR packages comprise dialect plug-ins (dialect), jpa specification plug-ins, orm plug-ins and jdbc plug-ins.
Specifically, the service package and the Mapper package are designed into two jar, and the Mapper package realizes the method of defining the interface DAO in the service package, wherein the Mapper can be an interface of mybaits or an implementation class. The Mapper inheriting the DAO may be an interface or an implementation class. If the interface can be the mapper definition of mybatis, the sql on the method can be the semantic grammar of the dialect determined based on the default database grammar, and the dialect plugin intercepts mybatis through an interconnector in the running process according to the connection information of the database. The DQL toolkit only comprises jar, only tool class use, and sql can be developed based on the semantic grammar of dialects; the DQL toolkit generates the Mapper package of other types of database devices according to semantics. The JDBC plug-in package provided in this embodiment is a data structure of two data structures, namely DataRow and DataSet, which are oriented to dynamic data sources, tables and columns during operation and adopt a domain driving congestion model. And (3) performing the mapping processing of the DataRow processing table field and the Map, and performing the mapping processing of the DataRow processing query set and the Map. The database JDBC plug-in provides data access services for map data structures that provide basic database operations such as DMLService operations, DDLService, metaDataService, etc.
Specifically, the ORM concept is also adopted, the Provider pair DDL operation of mybatis is extended, the DML operation is converted into the object-to-image operation, after the object-to-image operation is converted into the java object-to-image operation, a developer can only determine the java object-to-image definition, a database client can read the variable definition of the java class through the image-to-image conversion component, the database connection information is used for judging the type of the database connected by the system, and the dialect conversion component is used for converting the field name of the java class definition into the insert, update, delete and select sql grammar of the corresponding database. Therefore, the definition of java object is converted into sql language from different databases through the dialect component, and the adaptation of different databases is indirectly and automatically completed by the system.
As shown in fig. 6, a specific implementation procedure of the database operation method is described in detail:
s01: and writing the java object under the model module of the service jar by using a third party ORM. Specifically, a java object, such as mybatis, can be written under a model module of a service jar through a third party ORM middleware of project requirement integration.
S02: aiming at the addition, deletion and modification of the single table, the Java object can be operated by using the built-in function of the ORM. Specifically, the operation on the java object can be realized through an API provided by mybatis plus.
S03: if a complex multi-table SQL query is written, defining a DAO interface at a service Jar, and realizing mysq grammar under a Mapper Jar package. Specifically, for hibernate, beetl SQL and the like, the associated annotation of the object is realized, and the linked list operation also directly operates the java object. As another example, mybatis uses native SQL to complete multi-table queries. The DAO interface is defined in the service Jar during the boot, and the mysq grammar is implemented in the Mapper Jar package.
S04: introducing a self-grinding dialect, checking whether sql under the mapper jar package supports cross-database conversion. If the support is ended; if not, S05 is performed. Specifically, at startup, it is checked whether SQL under the Mapper Jar package supports cross-database translation.
S05: if the personalized SQL uses a function which can not be converted by dialects, the adaptation Mapper layer Jar of different databases is realized aiming at the specific function. Specifically, the functions that the dialect component cannot convert are non-cross-platform functions, such as the montas_between functions, or functions corresponding to self-defined storage processes, and the like.
Specifically, using third party orm, a java object is written under the model module of service jqr; aiming at adding, deleting and modifying the single table, the java object can be operated by using a built-in function of orm; if complex multi-table SQL query sentences are written, defining a dao interface in a service jar, and realizing mySQL under a mapperjar package; checking whether SQL under the mapper jar packet supports cross-database conversion, and ending if so; if not, the personalized SQL uses functions that dialect cannot be converted, and the adaptation mapper layer jqr of different databases is implemented for specific functions.
According to the database operation method provided by the embodiment, the variable definition of the java class can be read through the image transferring component, the database type of the system connection is judged through the database connection information, and then the dialect transferring component converts the field name of the java class definition into the insert, update, delete and select SQL grammar of the corresponding database. Therefore, the definition of java object is converted into SQL language from different databases through dialect components, and the adaptation of different databases is indirectly and automatically completed by the system. Specifically, if it is determined that the object operation library can be passed through, the object such as DDL and DML is operated first; naming conventions such as single table DQL operations can be used with a naming convention operation library; the multi-table DQL operation is preferably automatically converted by the dialect plug-in; the personalized sql template was converted to the corresponding database template at encoding time using the dialect toolkit.
Specifically, the packet structure complies with the principle of 'relying on inversion principle', the service jar packet defines a persistence interface, and the DAO packet is realized. A database persistence layer scheme is implemented in the DAO package. In implementing a database persistence layer implementation in a DAO package, two implementation forms are supported: a) Using the "database dialect" approach, a dialect plug-in is implemented for mybatis, 90% of mid-span database sql runtime conversion is done by dialects. b) Database conversion tools were developed to accomplish conversion of coding levels by dialect definition for 10% of applications using a particular database function or function. With ORM, on DDL, the DML operation is converted into an object operation. For complex DQL operations, scan is performed by the toolkit for sql that cannot be converted by the dialect, and provision is given. The developer completes the adaptation development of the corresponding database for the special sql.
It should be noted that the database dialect (Database Language) refers to a set of grammar rules and data structures for representing the structure and properties of the database, and is one of important concepts in the theory of the database, and is used to construct various types of databases, including relational databases and non-relational databases, such as databases represented by E-R graphs, 9 NF-based graph databases, and the like. The database dialect in this embodiment is a data structure design and conversion logic that is self-developed according to the grammar rules of the database dialect for different databases, and may include a set of grammar rules that represent the relationships and properties of data, and rules for defining the entities, attributes, relationships, queries, and operations of these data in the database. The relational database dialect includes a set of grammar rules for representing TABLEs and data, such as CREATE TABLE, INSERT, UPDATE, DELETE statements, and the like. The non-relational database dialect includes grammar rules for representing the structure and attributes, relationships of the graph, vector, or directed graph.
The database operation method provided by the embodiment can realize the adaptation of different databases. The programming style of the developer is standardized, and a dynamic and offline conversion tool of the sql is provided. Therefore, the migration cost and the maintenance cost in the software iteration process are reduced, the development efficiency of each third party middleware can be improved, the accuracy of error prompt is ensured, a cross-database platform can be supported, and the universality is ensured.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a database operation device for realizing the above related database operation method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in one or more embodiments of the database operating device provided below may refer to the limitation of the database operating method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 7, there is provided a database operating apparatus 700 comprising: a writing module 701, an interface definition module 702 and a calling module 703, wherein:
the writing module 701 is configured to write, through the target middleware, a target module in the first type filing package to obtain a target object;
an interface definition module 702 for defining a call interface in a first type archive package in the event that it is determined that the target object is a target operation for a plurality of database devices;
and the calling module 703 is configured to perform a target operation on each target database device through the calling interface and the target object.
In one embodiment, the calling module is specifically configured to:
determining a second type filing package through the calling interface;
if the primary structured query language statement in the second type filing package is determined to support conversion across database equipment, converting the primary structured query language statement based on the target object to obtain a target structured query language statement;
and performing target operation on each target database device based on the target structured query language statement.
In one embodiment, the calling module is further specifically configured to:
Determining a target database type of the target object based on the database connection information of the target object;
and converting each field name of the target object into a grammar structure matched with the target database type through a dialect component and the native structured query language sentence to obtain the target structured query language sentence of the target database type.
In one embodiment, the calling module is specifically configured to:
if the primary structured query language statement in the second type filing package does not support the conversion of the cross-database equipment, determining a target database type of the target object based on the database connection information of the target object, and determining the second type filing package matched with the target database type;
and carrying out target operation on each target database device through the second type filing package matched with the target database type.
In one embodiment, the apparatus further comprises:
and the function operation module is used for performing target operation on the database equipment by using the target object through the function contained in the target middleware under the condition that the target object is determined to be the target operation aiming at the target database equipment.
The respective modules in the database operating apparatus described above may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 8. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing relevant data of the database device. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a database operating method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 8 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer readable storage medium is provided having stored thereon a computer program which when executed by a processor performs the steps of:
in a first aspect, the present application provides a database operating method. The method comprises the following steps:
writing a target module in a first type filing package through a target middleware to obtain a target object;
defining a call interface in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices;
And carrying out target operation on each target database device through the calling interface and the target object.
In one embodiment, the computer program is further adapted to perform the following steps when executed by a processor:
determining a second type filing package through the calling interface;
if the primary structured query language statement in the second type filing package is determined to support conversion across database equipment, converting the primary structured query language statement based on the target object to obtain a target structured query language statement;
and performing target operation on each target database device based on the target structured query language statement.
In one embodiment, the computer program is further adapted to perform the following steps when executed by a processor:
determining a target database type of the target object based on the database connection information of the target object;
and converting each field name of the target object into a grammar structure matched with the target database type through a dialect component and the native structured query language sentence to obtain the target structured query language sentence of the target database type.
In one embodiment, the computer program is further adapted to perform the following steps when executed by a processor:
if the primary structured query language statement in the second type filing package does not support the conversion of the cross-database equipment, determining a target database type of the target object based on the database connection information of the target object, and determining the second type filing package matched with the target database type;
and carrying out target operation on each target database device through the second type filing package matched with the target database type.
In one embodiment, the computer program is further adapted to perform the following steps when executed by a processor:
and under the condition that the target object is determined to be the target operation aiming at the target database equipment, performing the target operation on the database equipment by using the target object through the function contained in the target middleware.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
The user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (10)

1. A method of database operation, the method comprising:
writing a target module in a first type filing package through a target middleware to obtain a target object;
defining a call interface in the first type archive package in the event that the target object is determined to be a target operation for a plurality of database devices;
and carrying out target operation on each target database device through the calling interface and the target object.
2. The method of claim 1, wherein said performing a target operation on each of said target database devices via said call interface and said target object comprises:
determining a second type filing package through the calling interface;
if the primary structured query language statement in the second type filing package is determined to support conversion across database equipment, converting the primary structured query language statement based on the target object to obtain a target structured query language statement;
and performing target operation on each target database device based on the target structured query language statement.
3. The method of claim 2, wherein converting the native structured query language statement based on the target object to obtain a target structured query language statement comprises:
determining a target database type of the target object based on the database connection information of the target object;
and converting each field name of the target object into a grammar structure matched with the target database type through a dialect component and a native structured query language sentence to obtain the target structured query language sentence of the target database type.
4. The method according to claim 2, wherein said performing a target operation on each of said target database devices through said call interface and said target object comprises:
if the primary structured query language statement in the second type filing package does not support the conversion of the cross-database equipment, determining a target database type of the target object based on the database connection information of the target object, and determining the second type filing package matched with the target database type;
and carrying out target operation on each target database device through the second type filing package matched with the target database type.
5. The method according to claim 1, wherein the method further comprises:
and under the condition that the target object is determined to be the target operation aiming at the target database equipment, performing the target operation on the database equipment by using the target object through the function contained in the target middleware.
6. The method of any one of claims 1 to 5, wherein the target operation comprises one or more of an add operation, a query operation, a delete operation, and a modify operation.
7. A database operating apparatus, the apparatus comprising:
the writing module is used for writing in the target module in the first type filing package through the target middleware to obtain a target object;
an interface definition module for defining a call interface in the first type archive package if it is determined that the target object is a target operation for a plurality of database devices;
and the calling module is used for carrying out target operation on each target database device through the calling interface and the target object.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202311140175.8A 2023-09-05 2023-09-05 Database operation method, database operation device, computer equipment and storage medium Pending CN117112538A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311140175.8A CN117112538A (en) 2023-09-05 2023-09-05 Database operation method, database operation device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311140175.8A CN117112538A (en) 2023-09-05 2023-09-05 Database operation method, database operation device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117112538A true CN117112538A (en) 2023-11-24

Family

ID=88799952

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311140175.8A Pending CN117112538A (en) 2023-09-05 2023-09-05 Database operation method, database operation device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117112538A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160224667A1 (en) * 2015-02-04 2016-08-04 Xinyu Xingbang Information Industry Co., Ltd. Method and system of implementing an integrated interface supporting operation in multi-type databases
CN111858645A (en) * 2020-07-09 2020-10-30 上海达梦数据库有限公司 Database object processing method, device, equipment and storage medium
CN114090613A (en) * 2021-11-19 2022-02-25 恒生电子股份有限公司 Program statement conversion method, device, equipment and storage medium
CN114138240A (en) * 2021-11-24 2022-03-04 杭州安恒信息技术股份有限公司 Java object generation method, system, computer equipment and readable storage medium
CN114925142A (en) * 2022-04-21 2022-08-19 山东浪潮通软信息科技有限公司 Multi-type database compatibility method, device, equipment and medium of ORM framework
CN115729912A (en) * 2022-11-08 2023-03-03 杭州趣链科技有限公司 Database access system, database access method, computer device, and storage medium
CN115756634A (en) * 2022-11-03 2023-03-07 深圳华云信息系统有限公司 Database object relational mapping model establishing method, device, equipment and medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160224667A1 (en) * 2015-02-04 2016-08-04 Xinyu Xingbang Information Industry Co., Ltd. Method and system of implementing an integrated interface supporting operation in multi-type databases
CN111858645A (en) * 2020-07-09 2020-10-30 上海达梦数据库有限公司 Database object processing method, device, equipment and storage medium
CN114090613A (en) * 2021-11-19 2022-02-25 恒生电子股份有限公司 Program statement conversion method, device, equipment and storage medium
CN114138240A (en) * 2021-11-24 2022-03-04 杭州安恒信息技术股份有限公司 Java object generation method, system, computer equipment and readable storage medium
CN114925142A (en) * 2022-04-21 2022-08-19 山东浪潮通软信息科技有限公司 Multi-type database compatibility method, device, equipment and medium of ORM framework
CN115756634A (en) * 2022-11-03 2023-03-07 深圳华云信息系统有限公司 Database object relational mapping model establishing method, device, equipment and medium
CN115729912A (en) * 2022-11-08 2023-03-03 杭州趣链科技有限公司 Database access system, database access method, computer device, and storage medium

Similar Documents

Publication Publication Date Title
US11797558B2 (en) Generating data transformation workflows
US8489649B2 (en) Extensible RDF databases
US9128996B2 (en) Uniform data model and API for representation and processing of semantic data
US20170322990A1 (en) Exporting and importing database containers
US20210209098A1 (en) Converting database language statements between dialects
US10437564B1 (en) Object mapping and conversion system
US20190361999A1 (en) Data analysis over the combination of relational and big data
CN113051268A (en) Data query method, data query device, electronic equipment and storage medium
CN112930529A (en) Generating software artifacts from conceptual data models
US11726999B1 (en) Obtaining inferences to perform access requests at a non-relational database system
CN115729951B (en) Data query method, system, device and computer readable storage medium
US11252257B2 (en) Dynamic rest access
US11797518B2 (en) Registering additional type systems using a hub data model for data processing
CN117421302A (en) Data processing method and related equipment
US11775517B2 (en) Query content-based data generation
Alkowaileet et al. Large-scale complex analytics on semi-structured datasets using AsterixDB and Spark
CN117112538A (en) Database operation method, database operation device, computer equipment and storage medium
US9910616B2 (en) Dynamic data access
US11521089B2 (en) In-database predictive pipeline incremental engine
US11860939B2 (en) Manipulating a table with an XML column in a database
WO2020201882A1 (en) Extensible data skipping
WO2023246188A1 (en) Data sharing method and related system
US20240134842A1 (en) Fine-grained decision on propagation of revalidation
CN110888895B (en) Association-based access control delegation
US11755620B1 (en) Invoking supported non-relational database operations to provide results consistent with commands specified in a relational query language

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination