Message generation method and related device
By combining data page query technology with XML streaming writer, the high memory usage problem caused by one-time loading of XML documents is solved, the efficient generation of large XML messages is achieved, and the system performance and stability are improved.
Patent Information
- Application Number
- CN202510973704.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-15
- Publication Date
- 2025-10-14
AI Technical Summary
In the prior art, loading DOM-based XML documents into memory at one time results in high memory usage, affecting system performance and stability, and is difficult to apply to large and complex XML message generation.
Adopting data paging query technology, the data is converted into XML format in batches through the XML streaming writer based on the mapping relationship between Java objects and XML nodes, avoiding loading a large amount of data at one time.
Improves system performance and stability, is suitable for large XML message generation, reduces memory usage, and increases data processing speed.
Smart Images

Figure CN120780770A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a message generation method and related device. BACKGROUND
[0002] Message refers to data converted into a standardized format according to a specific format and specification. Messages with a standardized format can be communicated and exchanged between different systems and applications.
[0003] At present, based on the Document Object Model (DOM), the entire Extensible Markup Language (XML) document can be loaded into the memory at one time, and a tree-shaped document object model (DOM tree) is constructed. By operating the DOM tree, an XML format message can be generated. However, since this method needs to load the XML document into the memory at one time, the memory occupation is high, which affects the performance and stability of the system, and it is difficult to be applied to large and complex XML message generation.
[0004] Therefore, an urgent need exists for a solution to solve the above technical problems. SUMMARY
[0005] In view of the above problems, the present application provides a message generation method and related device.
[0006] The embodiments of the present application disclose the following technical solutions:
[0007] In a first aspect, the embodiments of the present application provide a message generation method, comprising:
[0008] Based on the preset number of records per page and the initial value of the page number, the data list is queried to obtain a query result;
[0009] When the query result includes data in the data list, the data in the query result is converted into XML format data based on the mapping relationship between the Java object and the XML node through the XML stream writer;
[0010] Based on the preset number of page numbers, the data list is queried until the query result is empty;
[0011] When the query result is empty, a message is generated based on at least one XML format data.
[0012] In a possible implementation, when the query result includes data in the data list, the data in the query result is converted into data in XML format based on the mapping relationship between the Java object and the XML node through the XML stream writer, and the conversion includes:
[0013] When the query result includes data in the data list, the data queried is added to the object list of the SQL dataset.
[0014] The data in the object list is converted into data in XML format based on the mapping relationship between the Java object and the XML node through the XML stream writer.
[0015] In a possible implementation, when the query result includes data in the data list, the data queried is added to the object list of the SQL dataset, and the adding includes:
[0016] When the query result includes data in the data list, the data queried is encapsulated to obtain encapsulated data.
[0017] The encapsulated data is added to the object list of the SQL dataset.
[0018] The data in the object list is converted into data in XML format based on the mapping relationship between the Java object and the XML node through the XML stream writer, and the conversion includes:
[0019] The encapsulated data in the object list is converted into data in XML format based on the mapping relationship between the Java object and the XML node through the XML stream writer.
[0020] In a possible implementation, when the query result is empty, a message is generated based on at least one piece of the data in XML format, and the generating includes:
[0021] When the query result is empty, an end of the XML document is written, and the XML stream writer is closed.
[0022] A message is generated based on at least one piece of the data in XML format.
[0023] In a possible implementation, when the query result includes data in the data list, the data in the query result is converted into data in XML format based on the mapping relationship between the Java object and the XML node through the XML stream writer, and the conversion includes:
[0024] An end element is written.
[0025] In a possible implementation, before the querying the data list based on the preset number of records per page and the initial page number and obtaining the query result, the method further includes:
[0026] creating a StAX output factory and an XML stream writer;
[0027] writing the beginning of an XML document and a root element.
[0028] In a possible implementation, before the querying the data list based on the preset number of records per page and the initial page number and obtaining the query result, the method further includes:
[0029] mapping Java objects and XML nodes by using JABX annotations;
[0030] establishing an association relationship between Java objects based on primary keys and foreign keys of the data table.
[0031] Second aspect: the embodiment of the application provides a message generation device, comprising:
[0032] a first query unit, a conversion unit, a second query unit and a generation unit;
[0033] The first query unit is configured to query a data list based on a preset number of records per page and an initial page number, and obtain a query result.
[0034] The conversion unit is configured to, when the query result includes data in the data list, convert the data in the query result into data in an XML format based on a mapping relationship between Java objects and XML nodes by using an XML stream writer.
[0035] The second query unit is configured to query the data list based on a preset number of added page numbers until the query result is empty.
[0036] The generation unit is configured to generate a message based on at least one piece of the data in the XML format when the query result is empty.
[0037] In a possible implementation, the conversion unit is specifically configured to:
[0038] when the query result includes data in the data list, add the queried data to an object list of a SQL data set;
[0039] convert the data in the object list into data in an XML format based on a mapping relationship between Java objects and XML nodes by using an XML stream writer.
[0040] In a possible implementation, the conversion unit is specifically configured to:
[0041] when the query result includes data in the data list, encapsulating the queried data to obtain encapsulated data;
[0042] adding the encapsulated data to an object list of a SQL data set;
[0043] the data in the object list is converted into XML format data by the XML stream writer based on the mapping relationship between the Java object and the XML node, including:
[0044] the encapsulated data in the object list is converted into XML format data by the XML stream writer based on the mapping relationship between the Java object and the XML node.
[0045] In a possible implementation, the generating unit is specifically configured to:
[0046] when the query result is empty, writing an end of an XML document and closing the XML stream writer;
[0047] generating a message based on at least one of the XML format data.
[0048] In a possible implementation, the apparatus further includes a first writing unit.
[0049] the writing unit is configured to write an end element.
[0050] In a possible implementation, the apparatus further includes:
[0051] a creating unit and a second writing unit;
[0052] the creating unit is configured to create a StAX output factory and an XML stream writer;
[0053] the second writing unit is configured to write a beginning of an XML document and a root element.
[0054] In a possible implementation, the apparatus further includes a establishing unit.
[0055] the establishing unit is configured to use a JABX annotation mapping to establish a mapping relationship between a Java object and an XML node, and establish an association relationship between Java objects based on a primary key and a foreign key of a data table.
[0056] A third aspect: an embodiment of the present application provides a computer device, the computer device comprising: a processor and a memory;
[0057] the memory is configured to store program code and transmit the program code to the processor;
[0058] The processor is configured to execute the steps of the packet generation method according to the instructions in the program code.
[0059] A fourth aspect: the embodiments of the present application provide a computer readable storage medium, the computer readable storage medium stores a computer program, the computer program is executed by a processor to realize the steps of the packet generation method.
[0060] A fifth aspect: the embodiments of the present application provide a computer program product, when the computer program product runs on a computer, the computer executes the steps of the packet generation method.
[0061] Compared with the prior art, the present application has the following beneficial effects:
[0062] The embodiments of the present application provide a packet generation method and related devices, by querying the data list based on the preset number of records per page and the initial value of the page number, obtaining the query result; when the query result includes data in the data list, converting the data in the query result into XML format data based on the mapping relationship between the Java object and the XML node through the XML streaming writer; querying the data list based on the preset number of page numbers until the query result is empty; when the query result is empty, generating a packet based on at least one of the XML format data. In the embodiments of the present application, the data page query technology is used to write data from the database in batches, which can avoid the system performance problem caused by loading a large amount of data at one time, is suitable for the generation of large XML packets, and can improve the performance and stability of the system. BRIEF DESCRIPTION OF DRAWINGS
[0063] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0064] Figure 1 A flowchart of a packet generation method provided by the embodiments of the present application;
[0065] Figure 2 A data structure diagram provided by the embodiments of the present application;
[0066] Figure 3 A schematic diagram of a packet generation method provided by the embodiments of the present application;
[0067] Figure 4A structural schematic diagram of a message generation apparatus is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0068] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0069] Message refers to data converted into a standardized format according to a specific format and specification. Messages with a standardized format can be communicated and exchanged between different systems and application programs.
[0070] At present, based on a Document Object Model (DOM), an entire Extensible Markup Language (XML) document can be loaded into memory at one time, and a tree-shaped document object model (DOM tree) is constructed. By operating the DOM tree, an XML format message can be generated. However, since this method needs to load the XML document into memory at one time, the memory occupation is high, which affects the performance and stability of the system, and it is difficult to be applied to large and complex XML message generation.
[0071] Based on this, the embodiments of the present application provide a message generation method and related apparatus. By querying a data list based on a preset number of records per page and a page code initial value, a query result is obtained. When the query result includes data in the data list, by using an XML stream writer, the data in the query result is converted into XML format data based on a mapping relationship between a Java object and an XML node. The data list is queried based on a preset number of page codes until the query result is empty. When the query result is empty, a message is generated based on at least one XML format data. In the embodiments of the present application, the data page query technology is used to write data from the database in batches, which can avoid the system performance problem caused by loading a large amount of data at one time, is suitable for large XML message generation, and can improve the performance and stability of the system.
[0072] It should be noted that the user-related information and data involved in this application (including but not limited to transaction information, customer information, account information, transaction details, etc., as well as data used for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0073] The following combination Figure 1 Introducing a message generation method provided by an embodiment of the present application, Figure 1 A flowchart of a message generation method provided in an embodiment of the present application.
[0074] S101: Based on the preset number of records per page and the initial value of the page number, query the data list to obtain the query result.
[0075] In the method provided in the embodiment of the present application, before querying the data list based on the preset number of records per page and the initial value of the page number and obtaining the query results, JABX annotation mapping can be used to establish a mapping relationship between Java objects and XML nodes; based on the primary key and foreign key of the data table, an association relationship between Java objects can be established.
[0076] Java Architecture for XML Binding (JABX) is a technology for converting Java objects to XML data. It allows developers to map Java objects to XML data using annotations and provides tools for generating and parsing XML data.
[0077] In the embodiment of the present application, JABX annotation mapping is used to establish a mapping relationship between Java objects and XML nodes.
[0078] For example, Figure 2 As shown in the figure, this is a data structure diagram provided by an embodiment of the present application. This figure is an entity-relationship diagram (ER diagram), which can represent entities (Entity), attributes (Attributes) and relationships between entities (Relationship) in a data structure through intuitive symbols.
[0079] Specifically, Figure 2 The relationship between storing transaction information (Transaction), storing customer information (Customers), storing account information (Accounts), and storing transaction details (TransactionDetails) is shown in Figure 1.
[0080] In the embodiment of the present application, an association relationship between Java objects can be established based on the primary key and foreign key of the data table.
[0081] For example, Figure 2 Transaction is used as the main table, and associated with Customers, Accounts, and TransactionDetails tables. You can construct data query page turning logic and use restrictions (LIMIT) and increasing the number of pages (OFFSET) to achieve page turning.
[0082] Among them, LIMIT is used to limit the number of records per page, and OFFSET is used to skip the previous records.
[0083] In one possible implementation, by introducing a database access object (DAO) and configuring the number of records per page (pageSize) and the initial page number (pageNumber), the data list can be queried based on the preset number of records per page and the initial page number to obtain query results.
[0084] It is understood that the number of records per page and the initial value of the page number are not specifically limited in the embodiment of the present application, and can be set according to needs. For example, the number of records per page can be set to any value, and the initial value of the page number can be set to 1.
[0085] In one possible implementation, based on a preset number of records per page and an initial page number, before querying the data list, a StAX output factory and an XML stream writer can be created; the beginning and root element of the XML document are written so that the data list can be queried subsequently, and data is written based on the XML stream writer.
[0086] S102: When the query result includes data in the data list, convert the data in the query result into data in XML format based on the mapping relationship between Java objects and XML nodes through an XML stream writer.
[0087] In an embodiment of the present application, based on the preset number of records per page and the initial value of the page number, one page of data in the data list is queried each time, and each time data is queried, the data is written through the XML streaming writer to avoid memory overflow.
[0088] In one possible implementation, when the query results include data in a data list, the queried data is added to an object list of a Structured Query Language (SQL) dataset. The data in the object list is converted to XML format using an XML stream writer based on a mapping relationship between Java objects and XML nodes.
[0089] For example, when the query results include data in a data list, the queried data can be encapsulated to obtain encapsulated data, which is then added to an object list in the SQL dataset. Furthermore, the encapsulated data in the object list is converted to XML format using an XML stream writer based on the mapping relationship between Java objects and XML nodes.
[0090] S103: Based on the preset number of increasing pages, query the data list until the query result is empty.
[0091] In the embodiment of the present application, when the query result includes data in the data list, it is necessary to continue to query the data list based on a preset number of incremental pages (OFFSET) until the query result is empty.
[0092] In one possible implementation, when the query results include data from a data list, the data in the query results is converted to XML format using an XML stream writer based on the mapping relationship between Java objects and XML nodes. An end element (writeEndElement) can then be written. Based on this, the query continues within the data list based on a preset incremented page number (OFFSET).
[0093] S104: When the query result is empty, generate a message based on at least one data in the XML format.
[0094] In a possible implementation, when the query result is empty, the writing of the XML document may be completed and the XML stream writer may be closed; and a message may be generated based on at least one data in the XML format.
[0095] To sum up, in the embodiment of the present application, data paging query technology is used to write data from the database in batches, which can avoid system performance problems caused by loading a large amount of data at one time. It is suitable for the generation of large XML messages and can improve the performance and stability of the system.
[0096] For ease of understanding, the following Figure 3 The method provided in the embodiment of the present application is generally introduced as follows. Figure 3As shown in the figure, this figure is a schematic diagram of a message generation method provided in an embodiment of the present application.
[0097] S301: Initialize database connection.
[0098] In the embodiment of the present application, the database can be connected based on the DriverManager.getConnection method.
[0099] S302: Define SQL query statements.
[0100] The SQL query statement includes but is not limited to LIMIT and OFFSET parameters.
[0101] In the embodiment of the present application, paging query can be implemented based on the pre-constructed page query logic in combination with LIMIT and OFFSET.
[0102] S303: Create a data query object.
[0103] In an embodiment of the present application, an object can be created based on the Connection.prepareStatement method to execute SQL query statements.
[0104] S304: Set paging parameters.
[0105] The paging parameters include but are not limited to the number of records per page and the initial value of the page number.
[0106] For example, pageSize and pageNumber are defined, and the defined pageSize and pageNumber are bound to LIMIT and OFFSET variables in a SQL query statement based on the PreparedStatement.setInt method.
[0107] Among them, pageSize=LIMIT; OFFSET=(pageNumber-1)*pageSize.
[0108] S305. Create a StAX output factory.
[0109] Among them, the Steaming API for XML (StAX) is a streaming API for processing XML data. It allows developers to read and generate XML data event by event in a streaming manner.
[0110] S306: Create an XML stream writer.
[0111] S307: Write the beginning of the XML document.
[0112] S308. Write the root element.
[0113] In the embodiment of the present application, a StAX output factory (XML Output Factory) may be created to write XML data in the form of a stream through an XMLStreamWriter, where the XML data includes the beginning of an XML document (writeStartDocument) and a root element (writeStartElement).
[0114] After writing the XML document header and root element, you can perform subsequent steps to write the object elements of the main table.
[0115] S309: Execute the query.
[0116] In an embodiment of the present application, an SQL statement query can be executed based on the PrepareStatement.executeQuery method, and the query result can be stored in the ResultSet method.
[0117] S310, traverse the result set and return a data list.
[0118] Among them, the data list can be represented as ResultSet.
[0119] S311. Create database objects and encapsulate data.
[0120] S312: Add the encapsulated data to the object list of the corresponding SQL data set.
[0121] In an embodiment of the present application, the query results can be traversed based on the ResultSet.next method, each record can be added to the properties of the corresponding object for encapsulation, and finally the encapsulated object can be added to the object list.
[0122] S313: Check whether there is more data.
[0123] In the embodiment of the present application, by executing the DAO method and checking the data result, it is checked whether the query result is empty.
[0124] If the query result is not empty, that is, the query result includes the data in the data list, it means that there is more data, in which case S314 can be executed. If the query result is empty, it means that there is no more data, in which case S318 can be executed.
[0125] S314. Use JAXB serialization.
[0126] Java Architecture for XML Binding (JAXB) is a technology for converting Java objects to XML data. It allows developers to map Java classes to XML format through annotations and provides tools for generating and parsing XML data.
[0127] In the embodiment of the present application, the queried data can be converted into XML format by using JAXB serialization.
[0128] S315. Write the main table object element.
[0129] In the embodiment of the present application, the list objects may be processed one by one based on the XML stream writer and written into the object element tag in XML format.
[0130] S316: Write the end element.
[0131] In the embodiment of the present application, the end element can be written based on the writeEndElement statement.
[0132] S317. Increase the page number and continue searching.
[0133] If the query result is not empty, the page number can be increased based on OFFSET to continue executing S309-S313 until the query result is empty.
[0134] S318. End of writing the XML document.
[0135] Exemplarily, in an embodiment of the present application, the end of the XML document can be written based on the writeEndDocument statement.
[0136] S319. Close the XML stream writer.
[0137] S320: Output XML message.
[0138] In the embodiment of the present application, XML messages can be output based on the writer.toString statement and memory resources can be released.
[0139] To sum up, in the embodiment of the present application, data paging query technology is used to write data from the database in batches, which can avoid system performance problems caused by loading a large amount of data at one time. It is suitable for the generation of large XML messages and can improve the performance and stability of the system.
[0140] At the same time, in the embodiment of the present application, JAXB and StAX are combined to add batch processing logic in the data processing layer, which is suitable for large messages with complex data structures, can effectively reduce memory usage and improve data processing speed.
[0141] This application provides a message generating device, see Figure 4 This figure is a structural diagram of a message generation device provided in an embodiment of the present application. Its specific implementation method is consistent with the implementation method and technical effects recorded in the embodiment of the above method, and some contents will not be repeated here.
[0142] This embodiment of the present application provides a message generating device 4100, including:
[0143] A first query unit 4101, a conversion unit 4102, a second query unit 4103, and a generation unit 4104;
[0144] The first query unit 4101 is used to query the data list based on the preset number of records per page and the initial value of the page number to obtain the query result;
[0145] The conversion unit 4102 is configured to convert the data in the query result into XML format data based on the mapping relationship between Java objects and XML nodes through an XML stream writer when the query result includes data in the data list;
[0146] The second query unit 4103 is configured to query the data list based on a preset number of incremental pages until the query result is empty;
[0147] The generating unit 4104 is configured to generate a message based on at least one data in the XML format when the query result is empty.
[0148] In a possible implementation, the conversion unit is specifically configured to:
[0149] When the query result includes data in the data list, adding the queried data to the object list of the SQL data set;
[0150] The data in the object list is converted into data in XML format based on the mapping relationship between Java objects and XML nodes through an XML stream writer.
[0151] In a possible implementation, the conversion unit is specifically configured to:
[0152] When the query result includes data in the data list, encapsulating the queried data to obtain encapsulated data;
[0153] Add the encapsulated data to the object list of the SQL dataset;
[0154] The method of converting the data in the object list into data in XML format based on the mapping relationship between Java objects and XML nodes by using the XML stream writer includes:
[0155] The encapsulated data in the object list is converted into data in XML format based on the mapping relationship between Java objects and XML nodes through an XML stream writer.
[0156] In a possible implementation, the generating unit is specifically configured to:
[0157] When the query result is empty, the writing of the XML document ends and the XML stream writer is closed;
[0158] A message is generated based on at least one of the XML formatted data.
[0159] In a possible implementation, the device further includes: a first writing unit;
[0160] The writing unit is used to write the end element.
[0161] In a possible implementation, the apparatus further includes:
[0162] Create a unit and a second write unit;
[0163] The creation unit is used to create a StAX output factory and an XML stream writer;
[0164] The second writing unit is used to write the beginning and root element of the XML document.
[0165] In a possible implementation, the apparatus further includes: an establishing unit;
[0166] The establishing unit is used to establish a mapping relationship between Java objects and XML nodes using JABX annotation mapping; and to establish an association relationship between Java objects based on the primary key and foreign key of the data table.
[0167] To sum up, in the embodiment of the present application, data paging query technology is used to write data from the database in batches, which can avoid system performance problems caused by loading a large amount of data at one time. It is suitable for the generation of large XML messages and can improve the performance and stability of the system.
[0168] At the same time, in the embodiment of the present application, JAXB and StAX are combined to add batch processing logic in the data processing layer, which is suitable for large messages with complex data structures, can effectively reduce memory usage and improve data processing speed.
[0169] An embodiment of the present application provides a computer device, the computer device comprising: a processor and a memory;
[0170] The memory is used to store program code and transmit the program code to the processor;
[0171] The processor is configured to execute the steps of the message generation method described above according to the instructions in the program code.
[0172] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the message generation method described above are implemented.
[0173] An embodiment of the present application provides a computer program product. When the computer program product is run on a computer, the computer executes the steps of the message generation method described above.
[0174] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.
[0175] The above is merely one specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A message generation method, characterized in that: include: Based on the preset number of records per page and the initial value of the page number, query the data list to obtain the query results; When the query result includes data in the data list, converting the data in the query result into data in XML format based on the mapping relationship between Java objects and XML nodes through an XML stream writer; Based on the preset number of pages, the data list is queried until the query result is empty; When the query result is empty, a message is generated based on at least one data in the XML format.
2. The method according to claim 1, characterized in that When the query result includes data in the data list, converting the data in the query result into data in XML format based on the mapping relationship between Java objects and XML nodes through an XML stream writer includes: When the query result includes data in the data list, adding the queried data to the object list of the SQL data set; The data in the object list is converted into data in XML format based on the mapping relationship between Java objects and XML nodes through an XML stream writer.
3. The method according to claim 2, characterized in that When the query result includes data in the data list, adding the queried data to the object list of the SQL dataset includes: When the query result includes data in the data list, encapsulating the queried data to obtain encapsulated data; Add the encapsulated data to the object list of the SQL dataset; The method of converting the data in the object list into data in XML format based on the mapping relationship between Java objects and XML nodes by using the XML stream writer includes: The encapsulated data in the object list is converted into data in XML format based on the mapping relationship between Java objects and XML nodes through an XML stream writer.
4. The method according to claim 1, wherein When the query result is empty, generating a message based on at least one data in the XML format includes: When the query result is empty, the writing of the XML document ends and the XML stream writer is closed; A message is generated based on at least one of the XML formatted data.
5. The method according to any one of claims 1 to 4, characterized in that When the query result includes data in the data list, after converting the data in the query result into data in XML format based on the mapping relationship between Java objects and XML nodes through the XML stream writer, the method further includes: Write the end element.
6. The method according to any one of claims 1 to 4, characterized in that The method further includes querying the data list based on the preset number of records per page and the initial value of the page number, and obtaining the query result: Create a StAX output factory and an XML stream writer; Writes the beginning and root element of an XML document.
7. The method according to any one of claims 1 to 4, characterized in that The method further includes querying the data list based on the preset number of records per page and the initial value of the page number, and obtaining the query result: Use JABX annotation mapping to establish the mapping relationship between Java objects and XML nodes; Establish associations between Java objects based on the primary key and foreign key of the data table.
8. A message generating device, characterized in that: include: a first query unit, a conversion unit, a second query unit, and a generation unit; The first query unit is used to query the data list based on the preset number of records per page and the initial value of the page number to obtain the query result; The conversion unit is configured to convert the data in the query result into data in XML format based on a mapping relationship between Java objects and XML nodes through an XML stream writer when the query result includes data in the data list; The second query unit is configured to query the data list based on a preset number of incremental pages until the query result is empty; The generating unit is configured to generate a message based on at least one data in the XML format when the query result is empty.
9. A computer device, characterized in that: The computer device includes: a processor and a memory; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the steps of a message generating method according to any one of claims 1 to 7 according to the instructions in the program code.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the message generation method according to any one of claims 1 to 7 are implemented.
