A method for simplifying the addition, deletion, modification and query of one-to-many association tables in Java

By designing the public fields and business fields of the associated table in the Java program and using annotation mapping and database access layer interfaces, unified operations of the associated table are achieved, solving the problems of code duplication and high communication costs, and improving development efficiency and code readability.

CN119377223BActive Publication Date: 2025-09-09CHENGDU FANGLIAN CLOUD CODE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411530843.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-09-09
Estimated Expiration
2044-10-30

AI Technical Summary

Technical Problem

In Java program development, operations such as adding, deleting, modifying, and querying related tables require separate code logic. This leads to high code duplication, increased communication costs, and difficulty in unified management, affecting the overall efficiency of the project architecture.

Method used

Design the public fields and business fields of the association table, map the entity class fields through annotations, define the basic database access layer interface and operation interface, uniformly implement the addition, deletion, modification and query methods of the association table, and use Java to complete the logic code.

Benefits of technology

It reduces code duplication, shortens R&D time, reduces development costs, improves code readability and the versatility and reusability of associated tables, and facilitates subsequent unified modification and logic iteration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377223B_ABST
    Figure CN119377223B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for simplifying the addition, deletion, modification, and query of one-to-many association tables in a Java program. The method comprises the following steps: S1: designing an association table; S2: defining a basic entity class; S3: defining a business entity class; S4: defining a basic database access layer interface; S5: defining an association table database access interface; S6: defining an association table operation interface; and S7: adding addition, deletion, modification, and query methods for the association table to the association table operation interface, and completing the logic code in Java. The present invention reduces the need for repeated method definitions and SQL writing in association table functions during Java business development, shortening R&D time and saving development costs. The unified definition increases code readability, facilitates subsequent unified modification and logic iteration, and improves the versatility and reusability of association tables.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of one-to-many association tables, and in particular to a method for simplifying the addition, deletion, modification and query of one-to-many association tables in a Java program. Background Art

[0002] During current Java program development, a large number of operations involve adding, deleting, modifying, and querying related tables based on the master table. These operations require separate code logic and corresponding SQL statements. Most operations on related tables share some common logic, making the entire process cumbersome and repetitive. Furthermore, different people have different coding habits, so the naming of methods for adding, deleting, modifying, and querying related tables may also vary. This increases communication costs for R&D personnel when using corresponding methods, making it difficult to uniformly handle some common logic at the overall project architecture level. Summary of the Invention

[0003] The purpose of the present invention is to solve the above technical problems and provide a method for simplifying the addition, deletion, modification and query of one-to-many association tables in a Java program.

[0004] A method for simplifying the addition, deletion, modification, and query of a one-to-many association table in a Java program includes the following sub-steps:

[0005] S1: Design the association table: define the common fields and business fields of the association table, and check whether the field names are consistent;

[0006] S2: Define the base entity class: map the entity class fields to the associated table fields through annotations. The base entity class serves as the parent class of the business entity class.

[0007] S3: Define business entity classes: use annotations to indicate the corresponding table names and fields, and inherit the base entity class;

[0008] S4: Define the basic database access layer interface: use generic features to support different data entity classes;

[0009] S5: Define the database access interface for the associated table: inherit the basic database access layer interface, obtain basic operation methods, and expand according to the characteristics of the associated table;

[0010] S6: Define the associated table operation interface: obtain the primary table field name and database access interface of the associated table;

[0011] S7: Add the add, delete, modify and query methods of the association table in the association table operation interface, and use Java to complete the logic code.

[0012] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program, wherein step S1 includes the following sub-steps:

[0013] S11: Extract the common fields and fields required by business requirements in the intercom table design;

[0014] The common fields and fields required by business requirements include but are not limited to logical deletion identification, creation, modification, deletion time, and operator information;

[0015] S12: Unify the names of the extracted fields in the associated table and check whether the common field names are consistent:

[0016] If the common field names are inconsistent, redefine the common field names;

[0017] If they are consistent, continue the steps.

[0018] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program, wherein step S2 includes the following sub-steps:

[0019] S41: All business Mapper layer interfaces inherit the basic database access layer interface and specify the generic object as the main operation data entity class of the basic database access layer interface;

[0020] S42: Obtain the tables and fields of the operation according to the annotation mapping, and generate the corresponding database operation SQL.

[0021] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program is provided, wherein the database operation SQ includes adding, deleting, modifying and querying data.

[0022] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program, wherein step S7 includes the following sub-steps:

[0023] S71: Obtain the database access interface and obtain the table name and common fields of the associated table;

[0024] S72: Return the field names of the main table and assemble the SQL statements for adding, deleting, modifying, and querying the associated tables based on the main table.

[0025] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program is provided, wherein the operation interface of the association table is the core interface of the association table operation, and all repeated additions, deletions, modifications and queries of the association table are performed in the operation interface of the association table;

[0026] The repeated addition, deletion, modification and query of the associated table include but are not limited to querying the associated table list data according to the associated fields of the main table, and deleting the associated table data according to the associated fields of the main table.

[0027] The beneficial effects of the present invention are as follows: through a method for simplifying the addition, deletion, modification and query of one-to-many association tables in Java programs, the problems of repeated coding of a large amount of logic for association tables and the lack of unified management of repeated methods for some association tables in Java program development are solved; the repeated method definitions and SQL writing work in the association table functions during Java business development are reduced, thereby shortening R&D time and saving development costs; unified definition makes the code more readable, facilitates subsequent unified modification and logic iteration, and improves the versatility and reusability of association tables. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 The present invention is a flowchart of a method for simplifying the addition, deletion, modification and query of one-to-many association tables in a Java program. DETAILED DESCRIPTION

[0029] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, specific embodiments of the present invention are now described with reference to the accompanying drawings.

[0030] As attached Figure 1 As shown, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program includes the following sub-steps:

[0031] S1: Design the association table: define the common fields and business fields of the association table, and check whether the field names are consistent;

[0032] S2: Define the base entity class: map the entity class fields to the associated table fields through annotations. The base entity class serves as the parent class of the business entity class.

[0033] The S2 step is to reduce code duplication and facilitate business logic processing;

[0034] S3: Define business entity classes: use annotations to indicate the corresponding table names and fields, and inherit the base entity class;

[0035] The S3 step is used to subsequently parse the tables and fields corresponding to the business entity class;

[0036] S4: Define the basic database access layer interface: use generic features to support different data entity classes;

[0037] S5: Define the database access interface for the associated table: inherit the basic database access layer interface, obtain basic operation methods, and expand according to the characteristics of the associated table;

[0038] S6: Define the associated table operation interface: obtain the primary table field name and database access interface of the associated table;

[0039] Step S6 is for subsequent association table operation;

[0040] S7: Add the add, delete, modify and query methods of the association table in the association table operation interface, and use Java to complete the logic code.

[0041] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program, wherein step S1 includes the following sub-steps:

[0042] S11: Extract the common fields and fields required by business requirements in the intercom table design;

[0043] The common fields and fields required by business requirements include but are not limited to logical deletion identification, creation, modification, deletion time, and operator information;

[0044] S12: Unify the names of the extracted fields in the associated table and check whether the common field names are consistent:

[0045] If the common field names are inconsistent, redefine the common field names;

[0046] If they are consistent, continue the steps.

[0047] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program, wherein step S2 includes the following sub-steps:

[0048] S41: All business Mapper layer interfaces inherit the basic database access layer interface and specify the generic object as the main operation data entity class of the basic database access layer interface;

[0049] S42: Obtain the tables and fields of the operation according to the annotation mapping, and generate the corresponding database operation SQL.

[0050] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program is provided, wherein the database operation SQ includes adding, deleting, modifying and querying data.

[0051] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program, wherein step S7 includes the following sub-steps:

[0052] S71: Obtain the database access interface and obtain the table name and common fields of the associated table;

[0053] S72: Return the field names of the main table and assemble the SQL statements for adding, deleting, modifying, and querying the associated tables based on the main table.

[0054] Furthermore, a method for simplifying the addition, deletion, modification and query of a one-to-many association table in a Java program is provided, wherein the operation interface of the association table is the core interface of the association table operation, and all repeated additions, deletions, modifications and queries of the association table are performed in the operation interface of the association table;

[0055] The repeated addition, deletion, modification and query of the associated table include but are not limited to querying the associated table list data according to the associated fields of the main table, and deleting the associated table data according to the associated fields of the main table.

[0056] This solution uses a method for simplifying the addition, deletion, modification, and query of one-to-many association tables in Java programs. It solves the problems of repeated coding of association table logic and the lack of unified management of duplicate methods for some association tables during Java program development. It also reduces the need for repeated method definitions and SQL writing in association table functions during Java business development, shortening R&D time and saving development costs. Unified definitions make code more readable, facilitate subsequent unified modifications and logical iterations, and improve the versatility and reusability of association tables.

[0057] The basic principles, main features, and advantages of the present invention are shown and described above. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely illustrative of the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and modifications are intended to fall within the scope of the present invention. The scope of protection claimed in the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for simplifying the addition, deletion, modification and query of one-to-many association tables in a Java program, characterized in that: The following sub-steps are included: S1: Design the association table: define the common fields and business fields of the association table, and check whether the field names are consistent; S2: Define the base entity class: map the entity class fields to the associated table fields through annotations. The base entity class serves as the parent class of the business entity class. S3: Define business entity classes: use annotations to indicate the corresponding table names and fields, and inherit the base entity class; S4: Define the basic database access layer interface: use generic features to support different data entity classes; S5: Define the database access interface for the associated table: inherit the basic database access layer interface, obtain basic operation methods, and expand according to the characteristics of the associated table; S6: Define the associated table operation interface: obtain the main table field name and database access interface of the associated table; S7: Add add, delete, modify and query methods to the association table operation interface, and use Java to complete the logic code; The step S1 includes the following sub-steps: S11: Extract the common fields and fields required by business requirements in the intercom table design; The common fields and fields required by business requirements include logical deletion identification, creation, modification, deletion time, and operator information; S12: Unify the names of the extracted fields in the associated table and check whether the common field names are consistent: If the common field names are inconsistent, redefine the common field names; If they are consistent, continue the steps; The association table operation interface is the core interface for association table operations. All repeated additions, deletions, modifications, and queries of the association table are performed in the association table operation interface. The repeated addition, deletion, modification and query of the association table includes querying the association table list data according to the main table association field, and deleting the association table data according to the main table association field; The step S7 includes the following sub-steps: S71: Obtain a database access interface to obtain the table name and public fields of the associated table; S72: Return the field names of the main table and assemble the SQL statements for adding, deleting, modifying, and querying the associated tables based on the main table.

2. The method for simplifying the addition, deletion, modification and query of one-to-many association tables in a Java program according to claim 1, characterized in that: The step S4 includes the following sub-steps: S41: All business Mapper layer interfaces inherit the basic database access layer interface and specify the generic object as the main operation data entity class of the basic database access layer interface; S42: Obtain the tables and fields of the operation according to the annotation mapping, and generate the corresponding database operation SQL.

3. The method for simplifying the addition, deletion, modification and query of one-to-many association tables in a Java program according to claim 1, characterized in that: The database operation SQL includes adding, deleting, modifying and querying data.