Method and apparatus for dynamic extension of entity fields

CN117332014BActive Publication Date: 2026-09-22FUJIAN FUNO MOBILE COMM TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311029236.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-16
Publication Date
2026-09-22
Estimated Expiration
2043-08-16

AI Technical Summary

Technical Problem

[0010]但是,采用No-sql数据库实现方案,本身就存在局限性,NoSQL数据库虽然字段扩展能力较强,但是数据库不支持事务,存在较大的问题,难以满足应用场景需求

Benefits of technology

[0017]本发明的有益效果在于:本发明通过定义抽象类及抽象方法,让应用侧继承该抽象类并自定义实现该类的抽象方法。其一,所有扩展信息均由应用侧自定义,提升了扩展性,亦不存在数据库类型的限制;其二,采用独立的扩展实体表和扩展实体的设计方案,不存在污染源实体表和源实体类的情况存在;其三,无需预留字段、亦无需采用“实体-属性-值”的“纵表”设计方案,在资源利用率及性能上也优于常规方案。因此,本发明提升了扩展性及处理效率,亦不存在数据库类型的限制。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117332014B_ABST
    Figure CN117332014B_ABST
Patent Text Reader

Abstract

The application provides a dynamic expansion method and device of an entity field, which comprises the following steps of: defining an abstract entity class and annotation information in advance, defining an operation method of an expansion field in the abstract entity class, and using the annotation information to associate an expansion entity table with a source entity table which needs to be expanded; adding an expansion receiving field in the source entity table which needs to be expanded, and adding the operation method defined by the abstract entity class in a user information processing class; when an expansion entity and an expansion implementation class are received, the expansion implementation class inherits the abstract entity class defined in advance, and the expansion entity is transmitted, the expansion entity contains an entity identifier of the source entity, and the annotation information is added to the entity identifier; and the abstract class and the abstract method are defined, the application side inherits the abstract class, and the abstract method of the class is defined by the application side, so that the expansion and processing efficiency are improved, and the database type is not limited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for dynamically expanding entity fields. Background Technology

[0002] In daily R&D work, technical personnel often encounter the need to dynamically extend implementation class fields. However, for general entity classes, the framework has already encapsulated the relevant CRUD methods, making it inconvenient for applications to extend them independently, especially since different applications have different requirements for the type, length, and validation of extended fields. Currently, the industry's main solutions to the above-mentioned field extension problem are:

[0003] 1. Expand the required types of fields in the original table and add corresponding attributes to the corresponding entities. Directly discard all the operation methods of the entity class encapsulated by the original framework, rewrite the relevant methods of the entity class, and add the corresponding attribute-related operations.

[0004] However, the framework lacks extensibility. Extending fields requires rewriting all related operations, which is a significant workload and difficult for application users to accept. Alternatively, the framework can handle all extended fields through upgrades. While framework upgrades are reasonable for general attributes, for attributes closely related to the application, the application must rewrite the relevant methods to extend them.

[0005] 2. The framework reserves several fields in the design of database tables and entity classes for future expansion, such as: extend_field1, extend_field2, extend_field3, extend_field4, extend_field5, and extend_json; the field types are varchar and json respectively; the operations for the corresponding fields have also been encapsulated, and when applying extended fields, you only need to fill in the specific information in these fields.

[0006] However, reserving some fields in the framework can solve the scalability problem to some extent, but determining the number of reserved fields and their data types is not easy. To meet general needs, 5-10 fields are usually reserved, and the field type is character. This design scheme will waste some resources, and if the field type of the newly added attribute is not character, there will be some problems with query efficiency and table joins.

[0007] 3. The framework is designed using the Entity-attribute-value (EAV) pattern. The EAV database model stores model attributes as records in data tables. To add or remove attributes, only the corresponding records in the data tables need to be added or deleted, without modifying the database structure. This is commonly referred to in the industry as configuring business attribute values ​​using a "vertical table" approach.

[0008] However, the entity-attribute-value design scheme changes the query that could return all attributes from a single record to one that requires multiple records to return all attributes. This results in poor support for complex queries, especially table join queries, and also reduces query performance.

[0009] 4. Use a NoSQL database. NoSQL databases are characterized by their ability to implement flexible data models. Some databases, such as MongoDB and CouchDB, support dynamically adding fields and values.

[0010] However, the No-SQL database implementation has its limitations. Although NoSQL databases have strong field expansion capabilities, they do not support transactions, which is a significant problem and makes it difficult to meet the needs of application scenarios. Summary of the Invention

[0011] To address the aforementioned problems in the prior art, this invention provides a method and apparatus for dynamically expanding entity fields, which improves scalability and processing efficiency, and also eliminates limitations on database types.

[0012] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0013] In a first aspect, the present invention provides a method for dynamically expanding entity fields, comprising the steps of:

[0014] An abstract entity class and annotation information are predefined. The abstract entity class defines the operation methods of the extended fields. The annotation information is used to associate the extended entity table with the source entity table that needs to be extended.

[0015] Add extended receiving fields to the source entity table that needs to be expanded, and add the operation methods defined by the abstract entity class to the user information processing class;

[0016] When the application receives an extended entity and an extended implementation class that the user extends the source entity on the application side, the extended implementation class inherits the predefined abstract entity class and passes in the extended entity. The extended entity contains the entity identifier of the source entity and adds the annotation information to the entity identifier.

[0017] The beneficial effects of this invention are as follows: By defining abstract classes and abstract methods, this invention allows the application side to inherit from the abstract class and customize the implementation of the abstract methods. Firstly, all extended information is customized by the application side, improving scalability and eliminating database type limitations. Secondly, the design scheme of independent extended entity tables and extended entities avoids the possibility of polluting the source entity table and source entity class. Thirdly, it eliminates the need for reserved fields and the "entity-attribute-value" vertical table design scheme, resulting in better resource utilization and performance than conventional solutions. Therefore, this invention improves scalability and processing efficiency, and eliminates database type limitations.

[0018] Optionally, the steps also include:

[0019] Receive the extended Mapper from the user on the application side. The extended Mapper is used to implement the operation method on the database that stores the extended entity table and the source entity table.

[0020] The extended Mapper is referenced by the extended implementation class.

[0021] As described above, the database is connected to the Map layer where the database operation interface is located. By extending the service layer where the implementation class is located, the pre-defined operation methods are referenced. Thus, when the extended entity is operated in the extended implementation class, the corresponding operation methods in the Map layer are called to complete the operation on the corresponding data in the database.

[0022] Optionally, the operation method includes an addition method, a deletion method, a modification method, and a query method.

[0023] Optionally, the steps also include:

[0024] When a request to add a new entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be added is obtained through reflection, and the associated field is obtained through annotation information. The new entity identifier is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the add method of the abstract entity class is called to write the new field.

[0025] When a deletion request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the deletion method of the abstract entity class is called, and the entity identifier is passed in to delete the extended information.

[0026] When a modification request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be modified is obtained through reflection, and the associated field is obtained through annotation information. The entity identifier to be modified is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the modification method of the abstract entity class is called to write the extended information.

[0027] When a query request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the query method of the abstract entity class is called, and the entity identifier is passed in to retrieve the data information corresponding to the extended entity table. This data is then incorporated into the source entity class and returned.

[0028] As described above, this invention combines the custom extended entity with the basic source entity through the principles of class polymorphism, reflection mechanism, and object conversion, thereby further improving extensibility and processing efficiency.

[0029] Optionally, the parameter of the entity class used to pass in extended information within the abstract entity class is a generic parameter.

[0030] Secondly, the present invention provides a dynamic expansion device for an entity field, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:

[0031] An abstract entity class and annotation information are predefined. The abstract entity class defines the operation methods of the extended fields. The annotation information is used to associate the extended entity table with the source entity table that needs to be extended.

[0032] Add extended receiving fields to the source entity table that needs to be expanded, and add the operation methods defined by the abstract entity class to the user information processing class;

[0033] When the application receives an extended entity and an extended implementation class that the user extends the source entity on the application side, the extended implementation class inherits the predefined abstract entity class and passes in the extended entity. The extended entity contains the entity identifier of the source entity and adds the annotation information to the entity identifier.

[0034] Optionally, when the processor executes the computer program, it further performs the following steps:

[0035] Receive the extended Mapper from the user on the application side. The extended Mapper is used to implement the operation method on the database that stores the extended entity table and the source entity table.

[0036] The extended Mapper is referenced by the extended implementation class.

[0037] Optionally, the operation method includes an addition method, a deletion method, a modification method, and a query method.

[0038] Optionally, when the processor executes the computer program, it further performs the following steps:

[0039] When a request to add a new entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be added is obtained through reflection, and the associated field is obtained through annotation information. The new entity identifier is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the add method of the abstract entity class is called to write the new field.

[0040] When a deletion request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the deletion method of the abstract entity class is called, and the entity identifier is passed in to delete the extended information.

[0041] When a modification request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be modified is obtained through reflection, and the associated field is obtained through annotation information. The entity identifier to be modified is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the modification method of the abstract entity class is called to write the extended information.

[0042] When a query request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the query method of the abstract entity class is called, and the entity identifier is passed in to retrieve the data information corresponding to the extended entity table. This data is then incorporated into the source entity class and returned.

[0043] Optionally, the parameter of the entity class used to pass in extended information within the abstract entity class is a generic parameter.

[0044] The technical effects of the dynamic expansion device for entity fields provided in the second aspect are described in the relevant description of the dynamic expansion method for entity fields provided in the first aspect. Attached Figure Description

[0045] Figure 1 This is a schematic diagram of the main process of a dynamic expansion method for entity fields according to an embodiment of the present invention;

[0046] Figure 2 This is a schematic diagram of the overall architecture of a dynamic expansion method for entity fields according to an embodiment of the present invention;

[0047] Figure 3 This is a schematic diagram of the structure of a dynamic expansion device for an entity field according to an embodiment of the present invention.

[0048] [Explanation of Labels in the Attached Images]

[0049] 1: A dynamic expansion device for entity fields;

[0050] 2: Processor;

[0051] 3: Memory. Detailed Implementation

[0052] To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the present invention can be understood more clearly and thoroughly, and that the scope of the present invention can be fully conveyed to those skilled in the art.

[0053] Example 1

[0054] This embodiment is applicable to application scenarios that require dynamic expansion of entity class fields. By defining an abstract class and abstract methods, this embodiment allows the application to inherit from the abstract class and customize the implementation of the abstract methods, which improves extensibility and processing efficiency, and there are no restrictions on database types. The following is a detailed explanation of the specific method.

[0055] Please refer to Figures 1 to 2 A method for dynamically expanding entity fields, comprising the following steps:

[0056] S1. Predefine abstract entity classes and annotation information. Define operation methods for extended fields within the abstract entity class. Annotation information is used to associate the extended entity table with the source entity table that needs to be extended.

[0057] In this embodiment, the parameter of the entity class used to pass in extended information within the abstract entity class is a generic parameter.

[0058] like Figure 2 As shown, taking the extended user entity as an example, the source entity table is the user entity table. The specific implementation details are as follows:

[0059] 1. Define an abstract entity class: public abstract class AbstractSysUserExtendService <t>This is used to extend the user entity table, where... <t>The entity class used to pass in extended information defines the relevant add, delete, modify, and query methods in the abstract entity class. These methods include add, delete, modify, and query methods. For example:

[0060] New method: public void insertUserExtend(T extendInfo);

[0061] Deletion method: public int deleteUserExtendByUserId(Long id);

[0062] Modification method: public void updateUserExtend(T extendInfo);

[0063] Query method: public T selectUserExtendListByUserId(Long>id).

[0064] 2. Define the annotation @FieldAssociation. Use this annotation on the associated fields of the entity class corresponding to the extended information to determine the field association relationship between the user entity table and the extended entity table.

[0065] S2. Add extended receiving fields to the source entity table that needs to be extended, and add the operation methods defined by the abstract entity class to the user information processing class;

[0066] like Figure 2 As shown, taking the extended user entity as an example, the explanation continues as follows:

[0067] 3. Add the following field to the user entity table: private Map<String,Object> `extendInfo` is used to receive extended field information. When a user entity needs to extend a field, there is a corresponding extended entity. This extended entity is stored in the extended entity table, and the relevant information of the extended entity is stored in this extended field information in the user entity table to associate it with the extended entity in the extended entity table.

[0068] 4. Add corresponding extended field processing logic to the CRUD methods in the original user information processing class SysUserService. This extended field processing logic is triggered and executed when a user performs an operation on a user entity.

[0069] S3. When the application receives the extended entity and extended implementation class that the user extends the source entity on the application side, the extended implementation class inherits the predefined abstract entity class and passes in the extended entity. The extended entity contains the entity identifier of the source entity and adds annotation information to the entity identifier.

[0070] S4. Receive the extended Mapper from the user on the application side. The extended Mapper is used to implement operation methods on the database that stores the extended entity table and the source entity table.

[0071] S5. The extended implementation class references the extended Mapper.

[0072] The database is connected to the Map layer where the database operation interface is located. By extending the service layer where the implementation class is located, the pre-defined operation methods are referenced. Thus, when the extended entity is operated in the extended implementation class, the corresponding operation methods in the Map layer are called to complete the operation on the corresponding data in the database.

[0073] like Figure 2 As shown, taking the extended user entity as an example, the explanation continues as follows:

[0074] 5. User-defined extended entity: SysUserExtendEntity, which contains userId, and adds the annotation @FieldAssociation(value=”userId”) to this field, indicating that this field is associated with the userId field in the user entity table SysUser, where userId is the entity identifier.

[0075] 6. User-defined extended Mapper: SysUserExtendMapper, which implements the CRUD (Create, Read, Update, Delete) methods for the corresponding database.

[0076] 7. User-defined extension implementation class: SysUserExtendServiceImpl, where the extension implementation class inherits from AbstractSysUserExtendService. <t>An abstract class is used, and a generic parameter SysUserExtendEntity is passed in.

[0077] Then, the methods in SysUserExtendMapper are called respectively to implement the CRUD (Create, Read, Update, Delete) methods, for example:

[0078] New method: public void insertUserExtend(SysUserExtendEntityextendInfo);

[0079] Deletion method: public int deleteUserExtendByUserId(Long id);

[0080] Modification method: public void updateUserExtend(SysUserExtendEntityextendInfo);

[0081] Query method: public SysUserExtendEntity selectUserExtendListByUserId(Long>id);

[0082] Through the abstraction defined in the above framework and the user-defined implementation, the fields of user entities can be dynamically expanded.

[0083] Therefore, when a request to operate on a user entity is received, the following steps are also included:

[0084] S61. When a request to add a new entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be added is obtained through reflection, and the associated field is obtained through the annotation information. The new entity identifier is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the add method of the abstract entity class is called to implement the writing of the new field.

[0085] like Figure 2 As shown, when a new user entity needs to be added, the previous extended field processing logic is triggered. It checks if there is an implementation that inherits from the AbstractSysUserExtendService abstract class. If so, it means that corresponding extended information needs to be added, and this is done from the passed-in... <t>In the generic class, the entity class information corresponding to the extended information is obtained through reflection, and the associated field is obtained through @FieldAssociation. The newly generated userId is mapped to the associated field and stored in a Map along with the passed extended information field extendInfo. Through object conversion, the Map is converted into the corresponding extended information entity class, and the insertUserExtend(T extendInfo) method of AbstractSysUserExtendService is called to realize the data writing.

[0086] S62. When a deletion request for the source entity is received, determine whether there is an implementation that inherits from the abstract entity class. If so, call the deletion method of the abstract entity class and pass in the entity identifier to delete the extended information.

[0087] like Figure 2 As shown, when a user entity needs to be deleted, the previous extended field processing logic is triggered. It checks whether there is an implementation that inherits from the AbstractSysUserExtendService abstract class. If there is, it means that there is corresponding extended information that needs to be deleted. The deleteUserExtendByUserId(longid) method of AbstractSysUserExtendService is called, and the userId is passed in to delete the data.

[0088] S63. When a modification request for the source entity is received, determine whether there is an implementation that inherits from the abstract entity class. If so, obtain the entity class information corresponding to the first field to be modified through reflection and obtain the associated field through the annotation information. Map the entity identifier to be modified to the associated field and pass it into the Map along with the passed-in extended information. Convert the Map into the corresponding extended implementation class through object conversion. Then call the modification method of the abstract entity class to write the extended information.

[0089] like Figure 2 As shown, when modifications to a user entity are needed, similar to the add method, the previous extended field processing logic is triggered. It checks if there is an implementation that inherits from the AbstractSysUserExtendService abstract class. If so, it means there is corresponding extended information that needs to be modified, and the modification is performed from the passed-in... <t>In the generic class, the entity class information corresponding to the extended information is obtained through reflection, and the associated field is obtained through @FieldAssociation. The modified userId is mapped to the associated field and stored in a Map along with the passed extended information field extendInfo. Through object conversion, the Map is converted into the corresponding extended information entity class, and the updateUserExtend(TextendInfo) method of AbstractSysUserExtendService is called to implement data modification.

[0090] S64. When a query request for the source entity is received, determine whether there is an implementation that inherits from the abstract entity class. If so, call the query method of the abstract entity class, pass in the entity identifier to query the data information corresponding to the extended entity table, and merge it into the source entity class for return.

[0091] like Figure 2 As shown, when a query is needed for the user entity, the previous extended field processing logic is triggered. It checks whether there is an implementation that inherits from the AbstractSysUserExtendService abstract class. If there is, it means that there is corresponding extended information to return. It calls AbstractSysUserExtendService's selectUserExtendByUserId(longid), passes in the userId, retrieves the corresponding data information from the extended table, and merges the corresponding information into the extendInfo field in the user entity class, and returns the result.

[0092] In summary, this embodiment defines an abstract class and abstract methods, allowing the application to inherit from the abstract class and customize the implementation of its abstract methods. At the same time, it combines the custom extended entity with the basic source entity through the principles of class polymorphism, reflection, and object conversion, thereby improving scalability and processing efficiency, and there are no restrictions on database types.

[0093] Example 2

[0094] Please refer to Figure 3 A dynamic expansion device 1 for an entity field includes a memory 3, a processor 2, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, it implements the steps in Embodiment 1 above.

[0095] Since the apparatus / device described in the above embodiments of the present invention is an apparatus / device used to implement the method of the above embodiments of the present invention, those skilled in the art can understand the specific structure and modifications of the apparatus / device based on the method described in the above embodiments of the present invention, and therefore will not be described again here. All apparatus / devices used in the method of the above embodiments of the present invention fall within the scope of protection of the present invention.

[0096] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can 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, etc.) containing computer-usable program code.

[0097] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (devices), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions.

[0098] It should be noted that any reference numerals placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In claims that enumerate several means, several of these means may be embodied by the same hardware. The use of the terms first, second, third, etc., is merely for convenience of expression and does not indicate any order. These terms can be understood as part of the component names.

[0099] Furthermore, it should be noted that in the description of this specification, the terms "one embodiment," "some embodiments," "embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0100] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the claims should be interpreted to include both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0101] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, then this invention should also include these modifications and variations.< / t> < / t> < / t> < / t> < / t>

Claims

1. A method for dynamically expanding an entity field, characterized in that, Including the following steps: An abstract entity class and annotation information are predefined. The abstract entity class defines the operation methods of the extended fields. The annotation information is used to associate the extended entity table with the source entity table that needs to be extended. Add extended receiving fields to the source entity table that needs to be expanded, and add the operation methods defined by the abstract entity class to the user information processing class; When the application receives an extended entity and an extended implementation class that the user extends the source entity on the application side, the extended implementation class inherits the predefined abstract entity class and passes in the extended entity. The extended entity contains the entity identifier of the source entity and the annotation information is added to the entity identifier. The operation method includes methods for adding, deleting, modifying, and querying, and also includes the following steps: When a request to add a new entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be added is obtained through reflection, and the associated field is obtained through annotation information. The new entity identifier is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the add method of the abstract entity class is called to write the new field. When a deletion request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the deletion method of the abstract entity class is called, and the entity identifier is passed in to delete the extended information. When a modification request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be modified is obtained through reflection, and the associated field is obtained through annotation information. The entity identifier to be modified is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the modification method of the abstract entity class is called to write the extended information. When a query request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the query method of the abstract entity class is called, and the entity identifier is passed in to retrieve the data information corresponding to the extended entity table. This data is then incorporated into the source entity class and returned.

2. The method for dynamically expanding an entity field according to claim 1, characterized in that, It also includes the following steps: Receive the extended Mapper from the user on the application side. The extended Mapper is used to implement the operation method on the database that stores the extended entity table and the source entity table. The extended Mapper is referenced by the extended implementation class.

3. A method for dynamically expanding an entity field according to claim 1 or 2, characterized in that, The parameters of the entity class used to pass in extended information within the abstract entity class are generic parameters.

4. A dynamic expansion device for an entity field, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it performs the following steps: An abstract entity class and annotation information are predefined. The abstract entity class defines the operation methods of the extended fields. The annotation information is used to associate the extended entity table with the source entity table that needs to be extended. Add extended receiving fields to the source entity table that needs to be expanded, and add the operation methods defined by the abstract entity class to the user information processing class; When the application receives an extended entity and an extended implementation class that the user extends the source entity on the application side, the extended implementation class inherits the predefined abstract entity class and passes in the extended entity. The extended entity contains the entity identifier of the source entity and the annotation information is added to the entity identifier. The operation method includes methods for adding, deleting, modifying, and querying, and also includes the following steps: When a request to add a new entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be added is obtained through reflection, and the associated field is obtained through annotation information. The new entity identifier is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the add method of the abstract entity class is called to write the new field. When a deletion request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the deletion method of the abstract entity class is called, and the entity identifier is passed in to delete the extended information. When a modification request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the entity class information corresponding to the first field to be modified is obtained through reflection, and the associated field is obtained through annotation information. The entity identifier to be modified is mapped to the associated field and passed into the Map along with the passed-in extended information. The Map is converted into the corresponding extended implementation class through object conversion. Then, the modification method of the abstract entity class is called to write the extended information. When a query request for the source entity is received, it is determined whether there is an implementation that inherits from the abstract entity class. If so, the query method of the abstract entity class is called, and the entity identifier is passed in to retrieve the data information corresponding to the extended entity table. This data is then incorporated into the source entity class and returned.

5. The dynamic expansion device for an entity field according to claim 4, characterized in that, When the processor executes the computer program, it also performs the following steps: Receive the extended Mapper from the user on the application side. The extended Mapper is used to implement the operation method on the database that stores the extended entity table and the source entity table. The extended Mapper is referenced by the extended implementation class.

6. A dynamic expansion device for an entity field according to claim 4 or 5, characterized in that, The parameters of the entity class used to pass in extended information within the abstract entity class are generic parameters.

Citation Information

Patent Citations

  • Data processing method and device, equipment, storage medium and program product

    CN114116700A