CN107391529B - Method and device for realizing Object Relation Mapping (ORM) - Google Patents

Method and device for realizing Object Relation Mapping (ORM) Download PDF

Info

Publication number
CN107391529B
CN107391529B CN201710193517.0A CN201710193517A CN107391529B CN 107391529 B CN107391529 B CN 107391529B CN 201710193517 A CN201710193517 A CN 201710193517A CN 107391529 B CN107391529 B CN 107391529B
Authority
CN
China
Prior art keywords
data table
object model
data
model
mapping
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.)
Active
Application number
CN201710193517.0A
Other languages
Chinese (zh)
Other versions
CN107391529A (en
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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Advanced New Technologies 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 Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Priority to CN201710193517.0A priority Critical patent/CN107391529B/en
Publication of CN107391529A publication Critical patent/CN107391529A/en
Application granted granted Critical
Publication of CN107391529B publication Critical patent/CN107391529B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/25Integrating or interfacing systems involving database management systems
    • 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/289Object oriented databases

Abstract

The embodiment of the application discloses a method and a device for realizing Object Relationship Mapping (ORM). The method comprises the following steps: acquiring data table semantic configuration information, wherein the data table semantic configuration information comprises each field of a data table; generating an object model according to the semantic configuration information of the data table, wherein the object model comprises a mapping function and object attributes corresponding to the fields, and the mapping function comprises the following logics: directly accessing the object attribute to assign a value to the object attribute with the field or assign a value to the field with the object attribute; and mapping the object corresponding to the object model and the data in the data table according to the object model. By using the embodiment of the application, ORM can be realized without a reflection mechanism at the running period of the program, thereby being beneficial to reducing performance overhead and relieving the pressure on equipment.

Description

Method and device for realizing Object Relation Mapping (ORM)
Technical Field
The present application relates to the field of computer software technologies, and in particular, to a method and an apparatus for implementing Object Relational Mapping (ORM).
Background
The ORM is a technology for solving the phenomenon of mutual mismatch between an object-oriented database and a relational database.
The ORM may enable automatic persistence of objects in a program into a relational database, and may read data in the relational database as objects. Therefore, developers can concentrate on the work of each user interface layer of the service logic layer, most work of the data access layer can be automatically completed by the ORM, and development efficiency is improved.
In the prior art, generally, during the running period of a program, an object model is generated based on a reflection mechanism, and object attributes corresponding to the object model are accessed to implement ORM.
However, the reflection itself is subject to a large performance overhead, and therefore the stress on the device is large. Especially for mobile terminal devices, the problem of slow running or jamming of programs on the devices may be caused.
Disclosure of Invention
The embodiment of the application provides a method and a device for realizing ORM, which are used for solving the following technical problems in the prior art: during the program run time, the ORM is implemented based on the reflection mechanism, and the reflection itself has a large performance overhead, so that the stress on the device is large.
In order to solve the above technical problem, the embodiment of the present application is implemented as follows:
the method for realizing the ORM provided by the embodiment of the application comprises the following steps:
acquiring data table semantic configuration information, wherein the data table semantic configuration information comprises each field of a data table;
generating an object model according to the semantic configuration information of the data table, wherein the object model comprises a mapping function and object attributes corresponding to the fields, and the mapping function comprises the following logics: directly accessing the object attribute to assign a value to the object attribute with the field or assign a value to the field with the object attribute;
and mapping the object corresponding to the object model and the data in the data table according to the object model.
The device for realizing ORM provided by the embodiment of the application comprises:
the configuration module is used for acquiring semantic configuration information of a data table, wherein the semantic configuration information of the data table comprises each field of the data table;
a model module, configured to generate an object model according to the semantic configuration information of the data table, where the object model includes a mapping function and object attributes corresponding to the fields, and the mapping function includes the following logic: directly accessing the object attribute to assign a value to the object attribute with the field or assign a value to the field with the object attribute;
and the mapping module maps the object corresponding to the object model with the data in the data table according to the object model.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects: the ORM can be realized without a reflection mechanism at the running period of the program, thereby being beneficial to reducing the performance expense, relieving the pressure on equipment and partially or completely solving the problems in the prior art.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort.
Fig. 1 is a schematic flowchart of a method for implementing ORM according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a specific implementation of the method for implementing an ORM in an actual application scenario provided in an embodiment of the present application;
fig. 3 is a schematic structural diagram of an apparatus for implementing ORM corresponding to fig. 1 according to an embodiment of the present disclosure.
Detailed Description
The embodiment of the application provides a method and a device for realizing ORM.
In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Fig. 1 is a flowchart illustrating a method for implementing ORM according to an embodiment of the present disclosure. From the program perspective, the execution subject of the flow may be a client or a server; from a device perspective, the execution body of the flow may include, but is not limited to, the following devices: mobile phones, tablet computers, smart watches, car machines, personal computers, large and medium sized computers, computer clusters, and the like.
The process in fig. 1 may include the following steps:
s101: and acquiring semantic configuration information of the data table, wherein the semantic configuration information of the data table comprises all fields of the data table.
In the embodiment of the present application, the semantic configuration information of the data table may be designed in advance in a machine manner or a manual manner. Each data table can correspond to a set of data table semantic configuration information respectively.
The semantic configuration information of the data table may include related information of each field of the data table, such as a field name, a data type name corresponding to the field, a default value of the field, and the like. The semantic configuration information of the data table may further include the name of the data table, the name of the corresponding database, and information on whether the database is encrypted.
Generally, each field may be a column field of a data table, and any data record of the data table may be formed by each field and a value thereof.
In the embodiment of the present application, for convenience of subsequent use, the data table semantic configuration information may have a specific data format, for example, an extensible markup language (XML) format, a JSON format, or the like.
S102: generating an object model according to the semantic configuration information of the data table, wherein the object model comprises a mapping function and object attributes corresponding to the fields, and the mapping function comprises the following logics: directly accessing the object attribute to assign a value to the object attribute with the field or assign a value to the field with the object attribute.
In the embodiment of the present application, the object model belongs to a business logic model, and a corresponding object can be obtained by inputting a specified parameter into the object model, where the object is an instance of a class written in an object-oriented programming language.
Accordingly, the object may include object attributes corresponding to the fields. Based on these object attributes, mapping of the object to the data in the data table of each field, i.e., ORM, can be implemented.
In the embodiment of the present application, the object model may be in the form of source code, or may be in the form of a compiled product of the source code.
In the embodiment of the present application, based on the logic included in the mapping function, it is not necessary to generate an object model using a reflection mechanism at runtime to implement ORM, but rather, the object model generated in advance may be directly accessed to implement ORM by corresponding object attributes.
S103: and mapping the object corresponding to the object model and the data in the data table according to the object model.
In the embodiment of the present application, according to the object model, an object corresponding to the object model may be mapped to data in a data table, or data in the data table may be mapped to an object corresponding to the object model, and at least a part of reflection operations in the prior art may be avoided.
With the method of fig. 1, ORM can be implemented without a reflection mechanism at the running time of the program, which is beneficial to reduce performance overhead and pressure on the device, and can partially or completely solve the problems in the prior art.
Based on the method of fig. 1, the examples of the present application also provide some specific embodiments of the method, and further embodiments, which are described below.
In addition to the problems mentioned in the background, the prior art also has the problem of platform reuse. In particular, the scheme for implementing ORM in the prior art is difficult to be multiplexed on different platforms. The platform may refer to an operating system platform, such as an Android platform, an iOS platform, or the like; and may also refer to an application platform installed on an operating system, such as an HTML5 platform. The scheme of the application can also solve the platform multiplexing problem partially or completely.
Specifically, for step S102, the generating an object model according to the data table semantic configuration information may specifically include: acquiring an object model template designed aiming at a specified platform; and generating an object model according to the data table semantic configuration information and the object model template, wherein the platform comprises an operating system platform.
Therefore, corresponding object model templates can be designed for different platforms in advance. The semantic configuration information of the same data table can be used by combining with different object model templates, so that the scheme of the application can be conveniently reused on different platforms.
In practical applications, in order to reduce the cost, the object model template can be designed based on an existing template engine, such as a template engine of Mustache, Hogan, and the like. For ease of understanding, taking a template engine such as Mustache as an example, the step of generating the code of the object model may include the following steps:
reading semantic configuration information of a data table; the read semantic configuration information of the data table is used as input through a Mustache; reading a code character string of the object model template; binding corresponding contents in the semantic configuration information of the data table to a code character string of the object model template; and writing the bound character string into a code file, namely finishing the code generation of the object model.
In practical applications, the generation process of the code of the object model may also be: and compiling the object model template according to the semantic configuration information of the data table, wherein the compiled product is the code of the object model. The compiling process may be implemented by a predetermined compiling script.
In the embodiment of the present application, the code of the object model may be generated during compilation, and after the code of the object model is generated, the object model may be regenerated during runtime. Specifically, for step S102, the generating an object model according to the data table semantic configuration information may specifically include: in the compiling period, generating codes of an object model according to the semantic configuration information of the data table; and generating the object model according to the code of the object model in a runtime.
In this embodiment of the application, when the mapped party is data in the data table, for step S103, mapping the object corresponding to the object model and the data in the data table according to the object model may specifically include:
generating an object corresponding to the object model according to the object model;
performing for the data records in the data table:
reading each field of the data record;
according to the mapping function contained in the object model, the read fields are used for assigning values to corresponding object attributes in the object by directly accessing the object attributes in the object; and obtaining the assigned object as the object corresponding to the object model obtained by mapping the data record.
In this case, the mapping function may be, for example, of the form:
Figure BDA0001256803710000061
wherein, "this" represents the object, and "this. field _ field 3", "this. field _ field 1", and "this. field _ field 2" represent the object properties of the object; "cu" represents a field of a data record in the database extracted with a cursor as a variable of the cursor, "cu.getLong (0)" represents an extracted field corresponding to "this. field _ 3", "cu.getString (1)" represents an extracted field corresponding to "this. field _ 1", and "cu.getString (0)" represents an extracted field corresponding to "this. field _ 2". It can be seen that in the mapping function, the object attribute of the object is assigned with the corresponding field by directly accessing the object attribute.
Similarly, when the converted party is the object corresponding to the object model, for step S103, the converting the object corresponding to the object model and the data in the data table according to the object model specifically includes:
generating a data record of the data table;
executing the following steps for the object corresponding to the object model:
according to the mapping function contained in the object model, object attributes of the object corresponding to all fields of the data table are read out through directly accessing the object attributes in the object, and the read-out object attributes are used for assigning values to all the fields corresponding to the data record;
and obtaining the assigned data record as the data in the data table obtained by the object mapping.
In this case, the mapping function may be, for example, of the form:
Figure BDA0001256803710000071
wherein, bindArg represents the array used for keeping the data record in the database, each element of the array represents a field of the data record separately, bindArg [0], bindArg [1], bindArg [2] are the elements of the array; "this" indicates the object, "this. field _ field 3", "this. field _ field 1", "this. field _ 2" indicates the extracted object attribute of the object, "this. field _ field 3" indicates the extracted object attribute corresponding to "bindArgs [0 ]", "this. field _ field 1" indicates the extracted object attribute corresponding to "bindArgs [1 ]", and "this. field _ 2" indicates the extracted object attribute corresponding to "bindArgs [2 ]". It can be seen that in the mapping function, the object attribute is used to assign a value to the corresponding field by directly accessing the object attribute of the object.
The foregoing describes a method for implementing ORM provided in an embodiment of the present application. For convenience of understanding, an embodiment of the present application further provides a flowchart of a specific implementation of the method for implementing an ORM in an actual application scenario, as shown in fig. 2.
In the scene, the database is located on mobile terminal equipment such as a mobile phone, corresponding object model templates are designed for two mobile operating system platforms such as an Android platform and an iOS in advance, and corresponding data table semantic configuration information is designed for data tables in the database in advance.
The process in fig. 2 may mainly include the following steps:
in the compiling period, transmitting the semantic configuration information of the data table into an object model code generator;
the object model code generator obtains an object model template corresponding to a specified platform according to the platform; the appointed platform is an Android platform or an iOS platform;
the object model code generator generates a code of an object model suitable for a specified platform according to the semantic configuration information of the data table and the object model template;
the application of the Android platform or the iOS platform on the mobile terminal equipment calls the code of the corresponding object model to generate the object model in the operation period so as to realize ORM, and the object attribute corresponding to the object model can be directly accessed in the ORM process, so that the reflection operation can be avoided.
The embodiment of the present application further provides semantic configuration information of a data table in the scenario as an example, where the semantic configuration information of the data table is in an XML format, as follows:
Figure BDA0001256803710000081
Figure BDA0001256803710000091
in the data table semantic configuration information: the "table" tag represents a data table in the database, under the "table" tag, the "name" tag represents the name of the data table, and the "field" tag represents a field in the data table; under the "field" tag, the "name" tag represents the name of the field, the "type" tag represents the data type of the field, and the "default" tag represents the default value of the field; the "Index" tag indicates the Index of the field.
According to the data table semantic configuration information, codes of object models generated correspondingly by the Android platform and the iOS platform can be respectively, and the codes can include tag values in the data table semantic configuration information as object attributes, and can also include the mapping functions and the like. The codes of the object models corresponding to different platforms are similar in service logic, and the main difference is the adopted programming language, the Android platform adopts java, and the iOS platform adopts Objective-C.
Based on the same inventive concept, the embodiment of the present application further provides a device corresponding to the method for implementing ORM, as shown in fig. 3.
Fig. 3 is a schematic structural diagram of an apparatus for implementing ORM corresponding to fig. 1 provided in an embodiment of the present application, where the apparatus may be located on an execution body of the flowchart in fig. 1, and includes:
the configuration module 301 is configured to obtain semantic configuration information of a data table, where the semantic configuration information of the data table includes fields of the data table;
a model module 302, configured to generate an object model according to the semantic configuration information of the data table, where the object model includes a mapping function and object attributes corresponding to the fields, and the mapping function includes the following logic: directly accessing the object attribute to assign a value to the object attribute with the field or assign a value to the field with the object attribute;
and the mapping module 303 is configured to map an object corresponding to the object model with the data in the data table according to the object model.
Optionally, the model module 302 generates an object model according to the semantic configuration information of the data table, which specifically includes:
the model module 302 obtains an object model template for a specified platform design;
and generating an object model according to the data table semantic configuration information and the object model template, wherein the platform comprises an operating system platform.
Optionally, the model module 302 generates an object model according to the semantic configuration information of the data table, which specifically includes:
the model module 302 generates a code of an object model according to the semantic configuration information of the data table in the compiling period;
and generating the object model according to the code of the object model in a runtime.
Optionally, when the mapped party is data in the data table, the mapping module 303 maps the object corresponding to the object model and the data in the data table according to the object model, specifically including:
the mapping module 303 generates an object corresponding to the object model according to the object model;
performing for the data records in the data table:
reading each field of the data record;
according to the mapping function contained in the object model, the read fields are used for assigning values to corresponding object attributes in the object by directly accessing the object attributes in the object;
and obtaining the assigned object as the object corresponding to the object model obtained by mapping the data record.
Optionally, when the converted party is the object corresponding to the object model, the mapping module 303 converts the object corresponding to the object model and the data in the data table according to the object model, which specifically includes:
the mapping module 303 generates a data record of the data table;
executing the following steps for the object corresponding to the object model:
according to the mapping function contained in the object model, object attributes of the object corresponding to all fields of the data table are read out through directly accessing the object attributes in the object, and the read-out object attributes are used for assigning values to all the fields corresponding to the data record;
and obtaining the assigned data record as the data in the data table obtained by the object mapping.
The device and the method provided by the embodiment of the application are in one-to-one correspondence, so the device also has the beneficial technical effects similar to the corresponding method, and the beneficial technical effects of the method are explained in detail above, so the beneficial technical effects of the corresponding device are not described again.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (6)

1. A method for implementing Object Relational Mapping (ORM), comprising:
acquiring data table semantic configuration information, wherein the data table semantic configuration information comprises each field of a data table; each field comprises a column field of a data table;
generating an object model according to the semantic configuration information of the data table, specifically comprising: in the compiling period, generating codes of an object model according to the semantic configuration information of the data table; generating the object model according to the code of the object model in a runtime; the object model comprises a mapping function and object attributes corresponding to the fields, and the mapping function comprises the following logics: directly accessing the object attribute to assign a value to the object attribute with the field or assign a value to the field with the object attribute; generating an object model according to the semantic configuration information of the data table, specifically comprising: acquiring an object model template designed aiming at a specified platform; generating an object model according to the data table semantic configuration information and the object model template, wherein the platform comprises an operating system platform;
and mapping the object corresponding to the object model and the data in the data table according to the object model.
2. The method according to claim 1, wherein when the mapped party is data in the data table, the mapping the object corresponding to the object model and the data in the data table according to the object model specifically includes:
generating an object corresponding to the object model according to the object model;
performing for the data records in the data table:
reading each field of the data record;
according to the mapping function contained in the object model, the read fields are used for assigning values to corresponding object attributes in the object by directly accessing the object attributes in the object;
and obtaining the assigned object as the object corresponding to the object model obtained by mapping the data record.
3. The method according to claim 1, wherein when the converted party is an object corresponding to the object model, the converting the object corresponding to the object model and the data in the data table according to the object model specifically includes:
generating a data record of the data table;
executing the following steps for the object corresponding to the object model:
according to the mapping function contained in the object model, object attributes of the object corresponding to all fields of the data table are read out through directly accessing the object attributes in the object, and the read-out object attributes are used for assigning values to all the fields corresponding to the data record;
and obtaining the assigned data record as the data in the data table obtained by the object mapping.
4. An apparatus for implementing Object Relational Mapping (ORM), comprising:
the configuration module is used for acquiring semantic configuration information of a data table, wherein the semantic configuration information of the data table comprises each field of the data table; each field comprises a column field of a data table;
the model module generates an object model according to the semantic configuration information of the data table, and specifically comprises the following steps: the model module generates a code of an object model according to the semantic configuration information of the data table in a compiling period; generating the object model according to the code of the object model in a runtime; the object model comprises a mapping function and object attributes corresponding to the fields, and the mapping function comprises the following logics: directly accessing the object attribute to assign a value to the object attribute with the field or assign a value to the field with the object attribute; the model module generates an object model according to the data table semantic configuration information, and specifically includes: the model module acquires an object model template designed aiming at a specified platform; generating an object model according to the data table semantic configuration information and the object model template, wherein the platform comprises an operating system platform;
and the mapping module maps the object corresponding to the object model with the data in the data table according to the object model.
5. The apparatus according to claim 4, wherein when the mapped party is data in the data table, the mapping module maps the object corresponding to the object model with the data in the data table according to the object model, specifically including:
the mapping module generates an object corresponding to the object model according to the object model;
performing for the data records in the data table:
reading each field of the data record;
according to the mapping function contained in the object model, the read fields are used for assigning values to corresponding object attributes in the object by directly accessing the object attributes in the object;
and obtaining the assigned object as the object corresponding to the object model obtained by mapping the data record.
6. The apparatus according to claim 4, wherein when the converted object is an object corresponding to the object model, the mapping module converts the object corresponding to the object model and the data in the data table according to the object model, specifically including:
the mapping module generates a data record of the data table;
executing the following steps for the object corresponding to the object model:
reading object attributes of the object corresponding to the fields of the data table by directly accessing object attributes in the object according to the mapping function included in the object model, an
Assigning values to corresponding fields in the data record by using the read object attributes;
and obtaining the assigned data record as the data in the data table obtained by the object mapping.
CN201710193517.0A 2017-03-28 2017-03-28 Method and device for realizing Object Relation Mapping (ORM) Active CN107391529B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710193517.0A CN107391529B (en) 2017-03-28 2017-03-28 Method and device for realizing Object Relation Mapping (ORM)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710193517.0A CN107391529B (en) 2017-03-28 2017-03-28 Method and device for realizing Object Relation Mapping (ORM)

Publications (2)

Publication Number Publication Date
CN107391529A CN107391529A (en) 2017-11-24
CN107391529B true CN107391529B (en) 2020-12-08

Family

ID=60338346

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710193517.0A Active CN107391529B (en) 2017-03-28 2017-03-28 Method and device for realizing Object Relation Mapping (ORM)

Country Status (1)

Country Link
CN (1) CN107391529B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108897897B (en) * 2018-07-24 2021-01-05 艾普阳科技(深圳)有限公司 Data processing method and device
CN109522319A (en) * 2018-11-12 2019-03-26 北京懿医云科技有限公司 Data mapping method and device, electronic equipment, storage medium based on DSL
CN109814843A (en) * 2018-12-27 2019-05-28 中链科技有限公司 A kind of object-based page assignment method and system
CN109871657A (en) * 2019-03-21 2019-06-11 北京经纬恒润科技有限公司 A kind of data processing method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102841889A (en) * 2011-06-20 2012-12-26 中兴通讯股份有限公司 Method and device for achieving efficient database access based on ORM (object relational mapping) architecture
CN103853759A (en) * 2012-12-03 2014-06-11 方正国际软件(北京)有限公司 Self-adaptive form generation method and self-adaptive form generation system
CN103995781A (en) * 2014-06-10 2014-08-20 浪潮通用软件有限公司 Method for generating component testing use cases based on model
CN104899225A (en) * 2014-03-07 2015-09-09 北京四达时代软件技术股份有限公司 Object relational mapping method and device as well as processor

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016011677A1 (en) * 2014-07-25 2016-01-28 Hewlett-Packard Development Company, L.P. Local database cache
CN105550263A (en) * 2015-12-05 2016-05-04 百势软件(北京)有限公司 Assignment method and device in object-relational mapping

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102841889A (en) * 2011-06-20 2012-12-26 中兴通讯股份有限公司 Method and device for achieving efficient database access based on ORM (object relational mapping) architecture
CN103853759A (en) * 2012-12-03 2014-06-11 方正国际软件(北京)有限公司 Self-adaptive form generation method and self-adaptive form generation system
CN104899225A (en) * 2014-03-07 2015-09-09 北京四达时代软件技术股份有限公司 Object relational mapping method and device as well as processor
CN103995781A (en) * 2014-06-10 2014-08-20 浪潮通用软件有限公司 Method for generating component testing use cases based on model

Also Published As

Publication number Publication date
CN107391529A (en) 2017-11-24

Similar Documents

Publication Publication Date Title
CN109597661B (en) Service function configuration method and device
CN107562467B (en) Page rendering method, device and equipment
CN107644286B (en) Workflow processing method and device
CN107391529B (en) Method and device for realizing Object Relation Mapping (ORM)
CN107368292B (en) Resource compiling method and device
TW202001548A (en) Method and apparatus for developing application program
CN109241026B (en) Data management method, device and system
CN108268289B (en) Parameter configuration method, device and system for web application
CN109947643B (en) A/B test-based experimental scheme configuration method, device and equipment
CN110955714B (en) Method and device for converting unstructured text into structured text
CN108255471B (en) System configuration item configuration device, method and equipment based on configuration suite
CN107038058B (en) Code processing method and device
CN112597013A (en) Online development and debugging method and device
CN108846069B (en) Document execution method and device based on markup language
CN112307509A (en) Desensitization processing method, equipment, medium and electronic equipment
CN110245468A (en) A kind of Compilation Method, device, equipment and system
CN108170430B (en) Interface display method and system
CN114548744A (en) Business risk management method, device and equipment
CN114547024A (en) SQL statement risk detection method, device, equipment and medium
CN107391099B (en) Resource preprocessing method and device
CN111459573A (en) Method and device for starting intelligent contract execution environment
CN107239270B (en) Code processing method and device
CN110704742B (en) Feature extraction method and device
CN114780630A (en) Data display method, device and equipment
CN112732252A (en) Method and device for dynamically generating UI (user interface) and electronic equipment

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20201016

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201016

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

GR01 Patent grant
GR01 Patent grant