Entity object management and maintenance method and system based on AOP technology
Through the entity object management method of AOP technology, annotations and API functional interfaces are used to simplify data association operations in enterprise information systems, solve complex data association operation problems, and improve development efficiency and data processing accuracy.
Patent Information
- Application Number
- CN202410597632.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2024-08-30
AI Technical Summary
In enterprise information systems, developers need to write a large amount of hard coding to handle complex data association operations, resulting in high development costs, difficult maintenance, and prone to errors and omissions.
Adopt an entity object management method based on AOP technology, provide relationship annotations and associated query annotations for entities through annotators, use the parser to automatically parse entity relationships, call API functional interfaces to perform associated maintenance and query operations, and combine database operations with the object relationship mapping mode Convert it into an entity operation and use the life cycle hook function for callback.
It simplifies complex entity object association query, update and delete operations, improves development efficiency and data processing accuracy, reduces entity object association logic in business logic, and reduces development complexity.
Smart Images

Figure CN118567631A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to an entity object management and maintenance method and system based on AOP technology. Background Art
[0002] Most enterprise information systems are centered around processing business data. In the traditional process of developing enterprise information systems, developers need to write a lot of "hard coding" to operate business data, including adding, deleting, modifying, and checking data, which not only increases development costs, but also increases the difficulty of maintenance.
[0003] There are many types of associations between data objects in enterprise information systems, such as one-to-one, one-to-many, many-to-many, etc. The number of data associations will increase with the complexity of application system operations and the increase in data volume, so data association operations are becoming more and more complex. For developers, handling complex data association queries, association updates, and association deletion operations is not only time-consuming and labor-intensive, but also prone to errors and omissions.
[0004] Therefore, in the process of software development, how to simplify the association operations of entity objects and improve development efficiency has become an urgent problem to be solved. Summary of the invention
[0005] In view of the deficiencies in the prior art, the present invention proposes an entity object management and maintenance method and system based on AOP technology.
[0006] The first aspect of the present invention discloses an entity object management and maintenance method based on AOP technology, comprising:
[0007] Based on the annotator, each entity is provided with relationship annotations and relationship query annotations to maintain the relationship between entities. The parser automatically parses and obtains the abstract definition of the entity relationship in the annotation based on the reflection mechanism.
[0008] In response to data maintenance and data query instructions, call one or more API function interfaces for performing association maintenance operations and association query operations of entities in the framework, wherein the association maintenance operations perform entity association addition, association editing, association saving, and association deletion operations in an entity nested manner;
[0009] Obtain the abstract definition of the entity relationship through parsing, and transform the database operation into entity operation by integrating the object-relationship mapping mode through the operation executor to execute the operation instruction of the API functional interface, and return the callback information of the operation instruction through the lifecycle hook function based on the entity callback.
[0010] In an optional embodiment, the relationship annotation is used to define an abstract relationship between entities, wherein the abstract relationship includes a one-to-one subordinate relationship, a one-to-one ownership relationship, and a one-to-many ownership relationship.
[0011] In an optional embodiment, the relationship annotation also includes annotation attributes of element information and metadata information in the metaprogram, and the annotation attributes are configured as entity primary key, entity foreign key and associated deletion instructions, the default value of the entity primary key includes the associated class name and entity ID, and the default value of the entity foreign key includes the entity ID.
[0012] In an optional embodiment, the relationship query annotation is used to perform an entity association query operation through the annotated association query entity path, so as to decouple the association maintenance operation corresponding to the relationship annotation from the association query operation.
[0013] In an optional embodiment, the entity callback includes an entity callback interface and an entity callback registration center. The entity callback interface encapsulates a lifecycle hook function that performs database maintenance operations by controlling the associated maintenance operations of the entity. Business logic operations within the database lifecycle are completed based on the entity callback interface. The lifecycle hook function includes a function called before creating a new entity, a function called before updating an entity, a function called before saving an entity, a function called after saving an entity, a function called before deleting an entity, and a function called after deleting an entity.
[0014] In an optional embodiment, the abstract definition includes a relationship definition between an entity and an associated entity, an entity class definition between entities, and an entity path definition. The entities are infinitely nested through entity layers, the associated entity is in a subordinate relationship with the upper-level entity, and the entity class is an entity association relationship of the same entity layer.
[0015] In an optional embodiment, the association query operation recursively queries entities and related entities in the entity layer of one or more database tables based on the entity path field parsed by the annotation. The association query operation includes single query and batch query. The association save operation performs operational logic judgment of the associated entities based on annotation attributes, and calls the API function interface according to the operational logic judgment result to support the association addition, association editing, association saving and association deletion operations of entity-related associated entities.
[0016] The second aspect of the present invention discloses an entity object management and maintenance system based on AOP technology, the system comprising:
[0017] The entity layer includes entities, associated entities, relationship annotators, and relationship parsers. It is used to provide relationship annotations and relationship query annotations for maintaining the relationship between entities for each entity based on the annotator. The parser automatically parses and obtains the abstract definition of the entity relationship in the annotation based on the reflection mechanism.
[0018] The access layer is used to respond to data maintenance and data query instructions and call one or more API function interfaces for performing association maintenance operations and association query operations of entities in the framework. The association maintenance operations perform entity association addition, association editing, association saving, and association deletion operations in an entity nested manner;
[0019] The execution layer includes an operation executor, an object-relationship mapping pattern framework and an entity callback, which are used to obtain the abstract definition of the entity relationship through parsing. The operation executor integrates the object-relationship mapping pattern to convert the database operation into the entity operation to execute the operation instructions of the API functional interface, and the entity callback returns the callback information of the operation instruction through the lifecycle hook function.
[0020] The third aspect of the present invention discloses an entity object management and maintenance device based on AOP technology, comprising:
[0021] at least one processor, and
[0022] a memory communicatively connected to the at least one processor; wherein,
[0023] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the entity object management and maintenance method based on AOP technology as disclosed in any one of the first aspects of the present invention.
[0024] The fourth aspect of the present invention discloses a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the entity object management and maintenance method based on AOP technology as described in any one of the items disclosed in the first aspect of the present invention.
[0025] Compared with the prior art, the present invention has the following advantages:
[0026] The present invention adds associated entity fields to the entity on the basis of custom annotations that map database tables to application entities, and uses a framework to customize multiple runtime relationship annotations to annotate the associated entity fields. The annotations can declare primary and foreign keys to associate with each database table. When the application calls the framework API to implement association operations, the framework will reflect and parse the relationship annotations to obtain the association relationships in the database table, and at the same time add, edit, save, delete and query the associated entities, separating the general entity object association logic from the business logic to simplify complex entity object association queries, association updates and association deletion operations, thereby improving the development efficiency of entity object operations and the accuracy of data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0028] Figure 1 It is a flow chart of the entity object management and maintenance method based on AOP technology of the present invention;
[0029] Figure 2 It is a schematic diagram of the entity object management and maintenance system based on AOP technology of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0031] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0032] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0033] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0034] Before describing the embodiments of the present application, it is necessary to explain that:
[0035] AOP: AOP is the abbreviation of Aspect Oriented Programming, which means aspect-oriented programming. AOP is a continuation of OOP (object-oriented programming), a hot topic in software development, an important part of the Spring framework, and a derivative paradigm of functional programming.
[0036] Annotation: Annotation is a way and method provided by Java to associate any information and metadata with an element in a metaprogram. It is an interface that allows a program to obtain the Annotation object of a specified program element through reflection, and then obtain the metadata in the annotation through the Annotation object.
[0037] Reflection mechanism: In Java, reflection refers to the ability of a program to obtain internal information about program code, classes, objects, and member variables at runtime, and to operate on this information at runtime. Through reflection, Java programs can dynamically create objects, call methods, access and modify field values, and obtain various metadata information of classes.
[0038] Primary key: It can uniquely represent the data in the table. Using the primary key of the table can ensure the integrity of the entity. The primary key can be used to modify or delete the data in the table. It is also mainly used to establish connections between tables through primary and foreign key associations with other tables.
[0039] Foreign key: A key that connects two tables through a key in one table.
[0040] Object-relational mapping pattern: a technology designed to solve the mismatch between object-oriented and relational databases. For example, the ORM framework can be used as a bridge to connect to the database. As long as the mapping relationship between the persistent class and the table is provided, the ORM framework can refer to the information in the mapping file at runtime and persist the object to the database. In the embodiments of this application, the ORM framework is used as a preferred implementation.
[0041] In the embodiment of the present application, the data maintenance system adopts the database association operation framework of relation-spring-boot-starter, and adopts the automatic configuration mechanism of starter in spring-boot, which can abandon the previous complicated configuration and integrate it into the starter. The user only needs to introduce the starter dependency in Maven, and SpringBoot can automatically scan the information to be loaded and start the corresponding default configuration. Starter allows us to get rid of the trouble of processing various dependent libraries and configuring various information, and reduces the workload of developers to write a large amount of code for processing database operations.
[0042] The advantages of using the database association operation framework in the embodiments of the present application are compared below through multiple existing similar frameworks:
[0043] MyBat is: It requires writing SQL join table queries, has redundant code, low development efficiency, and does not support lifecycle hook functions.
[0044] MyBat isP l us: only supports single-table add, delete, query and modify operations. Multi-table associated add, delete, modify and query need to rely on the underlying MyBat is, and cannot support lifecycle hook functions.
[0045] Hibernate: supports adding, deleting, modifying and searching multiple tables. The underlying layer of the association query uses join. When multiple table association queries are involved, the query becomes increasingly complex based on the number of tables. It also does not support lifecycle hook functions.
[0046] relation-spr i ng-boot-starter: It conveniently supports multi-table association addition, deletion, modification, and query operations through association annotations and association operation APIs, and can support lifecycle hook functions.
[0047] It should be noted that in the business logic, the front end usually names the entity object as entity, while the development back end usually names the entity object as object. In fact, entities, objects and entity objects all represent instances of entity classes. In this application, the instances of entity classes are mainly named by entities, and objects or entity objects, like entities, also represent instances of entity classes.
[0048] Example 1
[0049] See also Figure 1 The embodiment of the present invention discloses an entity object management and maintenance method based on AOP technology, which is applied to an associated entity data maintenance system, and is characterized in that the method comprises:
[0050] S1: Based on the annotator, each entity is provided with relationship annotations and relationship query annotations to maintain the relationship between entities. The parser automatically parses and obtains the abstract definition of the entity relationship in the annotation according to the reflection mechanism;
[0051] S2: In response to data maintenance and data query instructions, call one or more API function interfaces for performing association maintenance operations and association query operations of entities in the framework, wherein the association maintenance operations perform entity association addition, association editing, association saving, and association deletion operations in an entity nested manner;
[0052] Specifically, entity nesting refers to an entity object containing another entity object. This relationship is usually a one-to-many or many-to-many relationship. Through entity nesting, related data can be organized together to form a more complete and rich data structure. In JAVA, entity nesting is often implemented through class member variables, that is, defining an object of another class as a member variable in a class;
[0053] Furthermore, entity nesting is often used to represent complex data structures or business logic. For example, in a travel management system, a tour group may be composed of multiple tourists, each of whom may carry multiple pieces of luggage. A class can be designed to represent the tour group, which contains multiple tourist objects, and each tourist object contains multiple luggage objects. The operation mode of the database table can be transformed through entity nesting. The development efficiency of database-related operations and the accuracy of data processing can be improved by using entity operations.
[0054] S3: Obtain the abstract definition of the entity relationship obtained through analysis, and transform the database operation into the entity operation by integrating the object-relational mapping mode through the operation executor to execute the operation instruction of the API functional interface, and return the callback information of the operation instruction through the life cycle hook function based on the entity callback.
[0055] Specifically, the framework uses Executor to abstract database operations. Executor is not strongly bound to a specific third-party ORM framework. Any third-party ORM framework can complete specific database operations by implementing the Executor abstract layer. Databases include but are not limited to MySQL, PgSQL, and Oracle.
[0056] In an optional embodiment, the entity object management and maintenance system in the present application may select a database supporting an object-relational mapping mode or other database to execute the API functional interface provided by the access layer;
[0057] Specifically, the existing entity object management often uses the ORM framework to annotate the entity, so as to call the entity through the interface to perform management operations. Since the database association operation framework in the present application is not bound to the specific third-party object-relationship mapping mode framework (ORM framework), whether it is the database type supported by the ORM framework or the framework that does not support the ORM framework, as long as it can parse the relationship annotation based on the original entity annotation in the present application, it can call the API functional interface of the access layer in the present application. Therefore, the present application can support the management and maintenance of entity objects in different databases. It can be understood that on the basis of the entity annotation of the existing ORM framework, the present application encapsulates a relationship annotation and the API functional interface corresponding to the relationship annotation at the upper layer to realize the addition, editing, saving, deletion and query of entity objects, and can manage the entity object management and maintenance of the existing framework at the upper layer on the basis of the existing framework management database.
[0058] Furthermore, the above-mentioned existing entity object management often uses an ORM framework to annotate entities, usually mapping information in a database table to entities to complete custom annotations of entities in the framework, which is used to call the functional interface of a third-party ORM framework.
[0059] In an optional embodiment, the relationship annotation is used to define an abstract relationship between entities, wherein the abstract relationship includes a one-to-one subordinate relationship, a one-to-one ownership relationship, and a one-to-many ownership relationship.
[0060] In an optional embodiment, the relationship annotation also includes annotation attributes of element information and metadata information in the metaprogram, and the annotation attributes are configured as entity primary key, entity foreign key and associated deletion instructions, the default value of the entity primary key includes the associated class name and entity ID, and the default value of the entity foreign key includes the entity ID.
[0061] Specifically, the framework defines relationship annotations to represent the relationship between entities:
[0062] @BelongTo: indicates a one-to-one subordinate relationship between entities;
[0063] @HasOne: indicates that there is a one-to-one ownership relationship between entities;
[0064] @HasMany: indicates that there is a one-to-many ownership relationship between entities;
[0065] Definition is an abstract definition of entity relationships and associated query attributes;
[0066] Rel at i onDef initiation: The abstract definition of entity relationships, which can be divided into three types:
[0067] Be longToDef initi on: one-to-one entity dependency definition;
[0068] HasOneDefinition: One-to-one ownership relationship definition of an entity;
[0069] HasManyDefinition: One-to-many ownership relationship definition of an entity.
[0070] In an optional embodiment, the relationship query annotation is used to perform an entity association query operation through the annotated association query entity path, so as to decouple the association maintenance operation corresponding to the relationship annotation from the association query operation.
[0071] Specifically, in order to decouple business logic and database association query logic, the framework provides an association query annotation: @RelationInclud, which can be used to annotate the entity path of the association query. The framework executes specific association query logic by parsing the annotation, and developers do not need to manually write complex association query code.
[0072] In an optional embodiment, the entity callback includes an entity callback interface and an entity callback registration center. The entity callback interface encapsulates a lifecycle hook function that performs database maintenance operations by controlling the associated maintenance operations of the entity. Business logic operations within the database lifecycle are completed based on the entity callback interface. The lifecycle hook function includes a function called before creating a new entity, a function called before updating an entity, a function called before saving an entity, a function called after saving an entity, a function called before deleting an entity, and a function called after deleting an entity.
[0073] In an optional embodiment, the abstract definition includes a relationship definition between an entity and an associated entity, an entity class definition between entities, and an entity path definition. The entities are infinitely nested through entity layers, the associated entity is in a subordinate relationship with the upper-level entity, and the entity class is an entity association relationship of the same entity layer.
[0074] In an optional embodiment, the association query operation recursively queries entities and related entities in the entity layer of one or more database tables based on the entity path field parsed by the annotation. The association query operation includes single query and batch query. The association save operation performs operational logic judgment of the associated entities based on annotation attributes, and calls the API function interface according to the operational logic judgment result to support the association addition, association editing, association saving and association deletion operations of entity-related associated entities.
[0075] The present invention adds associated entity fields to the entity on the basis of custom annotations that map database tables to application entities, and uses a framework to customize multiple runtime relationship annotations to annotate the associated entity fields. The annotations can declare primary and foreign keys to associate with each database table. When the application calls the framework API to implement association operations, the framework will reflect and parse the relationship annotations to obtain the association relationships in the database table, and at the same time add, edit, save, delete and query the associated entities, separating the general entity object association logic from the business logic to simplify complex entity object association queries, association updates and association deletion operations, thereby improving the development efficiency of entity object operations and the accuracy of data processing.
[0076] Example 2
[0077] like Figure 2 As shown, the second aspect of the present invention discloses an entity object management and maintenance system based on AOP technology, the system comprising:
[0078] The database layer is used to select a database supporting an object-relational mapping mode to access the maintenance system as a carrier of entity metadata;
[0079] The entity layer includes entities, associated entities, relationship annotators, and relationship parsers. It is used to provide relationship annotations and relationship query annotations for maintaining the relationship between entities for each entity based on the annotator. The parser automatically parses and obtains the abstract definition of the entity relationship in the annotation based on the reflection mechanism.
[0080] The access layer is used to respond to data maintenance and data query instructions and call one or more API function interfaces for performing association maintenance operations and association query operations of entities in the framework. The association maintenance operations perform entity association addition, association editing, association saving, and association deletion operations in an entity nested manner;
[0081] The execution layer includes an operation executor, an object-relationship mapping pattern framework and an entity callback, which are used to obtain the abstract definition of the entity relationship through parsing. The operation executor integrates the object-relationship mapping pattern to convert the database operation into the entity operation to execute the operation instructions of the API functional interface, and the entity callback returns the callback information of the operation instruction through the lifecycle hook function.
[0082] In an optional embodiment, if Figure 2 The database layer shown is to show the database that can be connected to the entity object management and maintenance system. The entity object management and maintenance system in this application will not limit the database type.
[0083] In an optional embodiment, the entity callback includes an entity callback interface and an entity callback registration center. The entity callback interface encapsulates a lifecycle hook function that performs database maintenance operations by controlling the associated maintenance operations of the entity. Business logic operations within the database lifecycle are completed based on the entity callback interface. The lifecycle hook function includes a function called before creating a new entity, a function called before updating an entity, a function called before saving an entity, a function called after saving an entity, a function called before deleting an entity, and a function called after deleting an entity.
[0084] In an optional embodiment, the parser includes an annotation parser, a relationship annotation parser and a relationship query annotation parser. The annotation parser is used to parse the custom annotations of entities in the framework into annotation definitions, the relationship annotation parser is used to parse the abstract definitions in the entity relationship annotations, and the query annotation parser is used to parse the relationship query annotations of the entity association relationships obtained through the reflection mechanism in the framework. The query operation of entities in the database can be completed based on the association query annotations.
[0085] In an optional embodiment, a global manager RelationManager is also provided in the framework of the data maintenance system, and the components of the framework can be obtained and set through RelationManager. If the framework components cannot meet the business requirements, the components can be expanded or rewritten according to the framework specifications, and finally the RelationManager can be used to set the own component implementation.
[0086] The present invention adds associated entity fields to the entity on the basis of custom annotations that map database tables to application entities, and uses a framework to customize multiple runtime relationship annotations to annotate the associated entity fields. The annotations can declare primary and foreign keys to associate with each database table. When the application calls the framework API to implement association operations, the framework will reflect and parse the relationship annotations to obtain the association relationships in the database table, and at the same time add, edit, save, delete and query the associated entities, separating the general entity object association logic from the business logic to simplify complex entity object association queries, association updates and association deletion operations, thereby improving the development efficiency of entity object operations and the accuracy of data processing.
[0087] Example 3
[0088] The third aspect of the present invention discloses an entity object management and maintenance device based on AOP technology, comprising:
[0089] at least one processor, and
[0090] a memory communicatively connected to the at least one processor; wherein,
[0091] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the entity object management and maintenance method based on AOP technology as disclosed in any one of the first aspects of the present invention.
[0092] The computer device may be a terminal, and the computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. The processor of the computer device is used 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an entity object management and maintenance method based on AOP technology is implemented. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0093] Example 4
[0094] The fourth aspect of the present invention discloses a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the entity object management and maintenance method based on AOP technology as described in any one of the items disclosed in the first aspect of the present invention.
[0095] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the entity object management and maintenance method based on AOP technology as described above. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0096] Alternatively, if the above modules of the present invention are implemented in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to execute all or part of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, RAM, ROM, magnetic disks or optical disks.
[0097] Example 5
[0098] The difference between this embodiment 5 and embodiment 1 is that the following steps can also achieve the effect of improving the development efficiency of database association operations and the accuracy of data processing in embodiment 1. The specific steps are as follows:
[0099] Step 1: Define aspects for database operations and relationship maintenance; specifically, the following aspects can be defined: data access aspect, data persistence aspect, data validation aspect, and transaction management aspect. These aspects can cover all aspects of database operations, such as data reading, writing, updating, and deleting, as well as the maintenance and management of relationships.
[0100] Step 2: Use AOP technology to apply aspects to database operations and relationship maintenance; specifically, you can use AOP frameworks (such as Spring AOP) to implement dynamic proxying of aspects. When performing database operations, the AOP framework will automatically execute the code in the aspects, thereby automating the database operations. At the same time, the maintenance of relationships can also be automated by defining related aspects and AOP proxies.
[0101] Step 3: Perform database operations and maintain associations; specifically, database operations can be performed by calling database operation methods wrapped by the AOP proxy. At the same time, the maintenance of associations can also be achieved by calling related methods wrapped by the AOP proxy.
[0102] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An entity object management and maintenance method based on AOP technology, applied to an entity object management and maintenance system, characterized in that: The method comprises: Based on the annotator, each entity is provided with relationship annotations and relationship query annotations to maintain the relationship between entities. The parser automatically parses and obtains the abstract definition of the entity relationship in the annotation based on the reflection mechanism. In response to data maintenance and data query instructions, call one or more API function interfaces for performing association maintenance operations and association query operations of entities in the framework, wherein the association maintenance operations perform entity association addition, association editing, association saving, and association deletion operations in an entity nested manner; Obtain the abstract definition of the entity relationship through parsing, and transform the database operation into entity operation by integrating the object-relationship mapping mode through the operation executor to execute the operation instruction of the API functional interface, and return the callback information of the operation instruction through the lifecycle hook function based on the entity callback.
2. The entity object management and maintenance method based on AOP technology according to claim 1 is characterized in that: The relationship annotation is used to define the abstract relationship between entities, and the abstract relationship includes a one-to-one subordinate relationship, a one-to-one ownership relationship, and a one-to-many ownership relationship.
3. The entity object management and maintenance method based on AOP technology according to claim 2 is characterized in that: The relationship annotation also includes annotation attributes of element information and metadata information in the metaprogram, and the annotation attributes are configured as entity primary key, entity foreign key and associated deletion instructions. The default value of the entity primary key includes the associated class name and entity ID, and the default value of the entity foreign key includes the entity ID.
4. The entity object management and maintenance method based on AOP technology according to claim 1 is characterized in that: The relationship query annotation is used to execute the entity's relationship query operation through the annotated relationship query entity path, so as to decouple the relationship maintenance operation corresponding to the relationship annotation from the relationship query operation.
5. The entity object management and maintenance method based on AOP technology according to claim 1 is characterized in that: The entity callback includes an entity callback interface and an entity callback registration center. The entity callback interface encapsulates a lifecycle hook function that performs database maintenance operations by controlling the associated maintenance operations of the entity. Business logic operations within the database lifecycle are completed based on the entity callback interface. The lifecycle hook function includes a function called before creating a new entity, a function called before updating an entity, a function called before saving an entity, a function called after saving an entity, a function called before deleting an entity, and a function called after deleting an entity.
6. The entity object management and maintenance method based on AOP technology according to claim 1 is characterized in that: The abstract definition includes the relationship definition between the entity and the associated entity, the entity class definition between the entities and the entity path definition. The entities are infinitely nested through the entity layer. The associated entity is in a subordinate relationship with the upper-level entity, and the entity class is an entity association relationship of the same entity layer.
7. The entity object management and maintenance method based on AOP technology according to claim 6 is characterized in that: The association query operation recursively queries entities and associated entities in the entity layer of one or more database tables based on the entity path field parsed by the annotation. The association query operation includes single query and batch query. The association save operation performs operational logic judgment of the associated entities based on the annotation attributes, and calls the API function interface according to the operational logic judgment result to support the association addition, association editing, association saving and association deletion operations of entity-related associated entities.
8. An entity object management and maintenance system based on AOP technology, characterized in that: The system comprises: The entity layer includes entities, associated entities, relationship annotators, and relationship parsers. It is used to provide relationship annotations and relationship query annotations for maintaining the relationship between entities for each entity based on the annotator. The parser automatically parses and obtains the abstract definition of the entity relationship in the annotation based on the reflection mechanism. The access layer is used to respond to data maintenance and data query instructions and call one or more API function interfaces for performing association maintenance operations and association query operations of entities in the framework. The association maintenance operations perform entity association addition, association editing, association saving, and association deletion operations in an entity nested manner; The execution layer includes an operation executor, an object-relationship mapping pattern framework and an entity callback, which are used to obtain the abstract definition of the entity relationship through parsing. The operation executor integrates the object-relationship mapping pattern to convert the database operation into the entity operation to execute the operation instructions of the API functional interface, and the entity callback returns the callback information of the operation instruction through the lifecycle hook function.
9. An entity object management and maintenance device based on AOP technology, characterized in that: include: at least one processor, and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the entity object management and maintenance method based on AOP technology as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the entity object management and maintenance method based on AOP technology as described in any one of claims 1 to 7.
Citation Information
Cited By
Unified data object deletion processing method and system based on metadata
CN121433756A
