Packaging method, logic operation method, device, equipment and medium

By identifying null variables and custom encapsulation of data objects in PL/SQL to Java conversion, the problems of non-Java basic type operations and null value processing are solved, and higher syntax accuracy and code readability are achieved.

CN114661809BActive Publication Date: 2025-04-29CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210360839.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-07
Publication Date
2025-04-29
Estimated Expiration
2042-04-07

AI Technical Summary

Technical Problem

When converting PL/SQL to Java, variables of non-Java primitive types cannot directly perform expression symbolic operations, and null variables will cause null pointer exceptions during operation, resulting in indecent and difficult to understand.

Method used

By obtaining PL/SQL database data, filtering and identifying null variables, converting them to Java data, and customizing data object encapsulation for non-Java basic data types, selecting appropriate null instances to avoid null pointer exceptions.

Benefits of technology

Improves the accuracy of the conversion syntax and the correctness of data execution, avoids static method nesting, and improves the readability and user experience of the code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661809B_ABST
    Figure CN114661809B_ABST
Patent Text Reader

Abstract

The present invention discloses an encapsulation method, a logic operation method, a device, an equipment and a medium, which are widely used in the field of data conversion; the encapsulation method comprises: obtaining multiple database data in a PL / SQL database; screening multiple database data to obtain database data carrying null value variables; performing null value identification processing on null value variables in the database data carrying null value variables; converting all database data to obtain Java data; identifying the first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulating the Java data to obtain a custom data object; identifying the database data corresponding to the custom data object, and when the database data corresponding to the custom data object carries a null value identification, selecting the corresponding null value instance in the custom data object. The invention aims to improve the grammatical accuracy of conversion translation and the correctness of data execution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data conversion, and in particular to an encapsulation method, a logic operation method, a device, an equipment and a medium. Background Art

[0002] In PL / SQL, a variable that is only declared but not assigned a value or assigned a value of null can still perform numerical operations, and some system function input parameters also support variables with null values. However, when PL / SQL is converted to Java, direct type mapping is used. When performing operations in Java, variables that are converted to non-Java basic types cannot be directly operated using expression symbols, and if the variable value is null, a null pointer exception will occur during the operation.

[0003] For the above situation, the current common practice is to encapsulate expression calculation operations into a group of static methods, and convert the operations between variables from the original symbolic expressions to static methods. For example, the addition operation is translated from a+b to OptUtil.add(a,b). When performing complex symbolic expression operations, this processing leads to the nesting of a large number of static methods because each operation of the translated statement requires a static method call, which is extremely inelegant and creates a great obstacle for developers in reading. The encapsulation of the operation method does not conform to the operation behavior of the variable operation, which increases the burden on developers to understand the code. Summary of the invention

[0004] The following is a summary of the subject matter described in detail herein; this summary is not intended to limit the scope of the claims.

[0005] The embodiments of the present invention provide an encapsulation method, a logic operation method, an apparatus, a device and a medium, aiming to improve the grammatical accuracy of conversion translation and the correctness of data execution.

[0006] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present invention proposes a PL / SQL to Java encapsulation method, the encapsulation method comprising: obtaining multiple database data in a PL / SQL database; screening the multiple database data to obtain database data carrying null value variables; performing null value identification processing on the null value variables in the database data carrying null value variables; converting all the database data to obtain Java data; identifying a first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulating the Java data to obtain a custom data object; identifying the database data corresponding to the custom data object, and when the database data corresponding to the custom data object carries the null value identification, selecting the null value instance corresponding to the database data carrying the null value identification in the custom data object.

[0007] In some embodiments, after the first data type of the Java data is identified, the encapsulation method further comprises: when the first data type is a Java basic data type, performing a logic operation using the Java data.

[0008] In some embodiments, encapsulating the Java data to obtain a custom data object includes one of the following: when the Java data is numerical data, encapsulating the numerical data to obtain a numerical data object; when the Java data is date data, encapsulating the date data to obtain a date data object.

[0009] In some embodiments, the selecting of the null value instance corresponding to the database data carrying the null value identifier in the custom data object includes one of the following: when the database data is numerical data, selecting a null value instance of a numerical type in the custom data object; when the database data is date data, selecting a null value instance of a date type in the custom data object.

[0010] To achieve the above-mentioned purpose, the second aspect of an embodiment of the present invention provides a logical operation method for a custom data object. Based on the encapsulation method described in the first aspect above, the logical operation method includes: obtaining the custom data object and inputting the custom data object into the logical operation processing; performing null value instance recognition processing on the custom data object input into the logical operation processing, and selecting a corresponding processing method according to the null value instance recognition processing result.

[0011] In some embodiments, the corresponding processing method is selected according to the result of the null value instance identification processing, including one of the following: when there are one or more null value instances in the custom data object of the input logical operation processing, the logical operation processing is jumped out and the null value instance is returned; when there is no null value instance in the custom data object of the input logical operation processing, the logical operation processing is performed and the logical operation processing result is returned.

[0012] In some embodiments, the functions corresponding to the operation in the logic operation processing are called in a chain manner.

[0013] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present invention provides a PL / SQL to Java encapsulation device, the encapsulation device comprising: a data acquisition module, used to acquire multiple database data in a PL / SQL database; a null value identification module, used to screen and process the multiple database data to obtain database data carrying null value variables; a null value identification module, used to perform null value identification processing on the null value variables in the database data carrying null value variables; a database data to Java data conversion module, used to convert and process all the database data to obtain Java data; a Java data identification and encapsulation module, used to identify and process a first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulate the Java data to obtain a custom data object; a null value instance identification and encapsulation module, used to identify and process the database data corresponding to the custom data object, and when the database data corresponding to the custom data object carries the null value identifier, the null value instance corresponding to the database data carrying the null value identifier is selected in the custom data object.

[0014] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present invention provides a logical operation device for a custom data object. Based on the encapsulation device described in the third aspect, the logical operation device includes: a custom data object acquisition device, used to acquire the custom data object and input the custom data object into the logical operation processing; a null value instance identification module, used to perform null value instance identification processing on the custom data object input into the logical operation processing, and select a corresponding processing method according to the null value instance identification processing result; a data logical operation module, used to perform the logical operation processing.

[0015] To achieve the above-mentioned purpose, a fifth aspect of an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the encapsulation method for converting PL / SQL to Java as described in the first aspect and / or the logical operation method for custom data objects as described in the second aspect are implemented.

[0016] To achieve the above-mentioned purpose, the sixth aspect of an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to implement the PL / SQL to Java encapsulation method described in the first aspect and / or the logical operation method of the custom data object described in the second aspect when executing the computer program.

[0017] The beneficial effects of the embodiment of the present invention include: obtaining multiple database data in a PL / SQL database; screening multiple database data to obtain database data with null value variables; performing null value identification processing on the null value variables in the database data with null value variables; converting all the database data to obtain Java data; identifying the first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulating the Java data to obtain a custom data object; identifying the database data corresponding to the custom data object, and when the database data corresponding to the custom data object carries the null value identification, selecting the null value instance corresponding to the database data carrying the null value identification in the custom data object. Before the database data is converted, the null value variable is marked with a null value, and the corresponding null value instance is selected when it is converted to Java data, thereby avoiding the occurrence of logic operation exceptions and null pointer exceptions caused by the appearance of null values ​​in Java syntax, ensuring that the result of the logical operation processing output of the converted Java data is consistent with the result of the database data output, and at the same time ensuring the grammatical accuracy of the conversion and the correctness of data execution. Use custom data objects to encapsulate data of non-Java basic data types to avoid the nesting of a large number of static methods, which would otherwise make the overall code extremely inelegant and bloated. This improves the readability of the code and the elegance of expression statements, greatly enhancing the user experience.

[0018] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the technical solution of the present invention and do not constitute a limitation on the technical solution of the present invention.

[0020] Figure 1 is a schematic diagram of a system architecture platform for a packaging method and a logic operation method provided by an embodiment of the present invention;

[0021] Figure 2 It is a flow chart of the encapsulation method of converting PL / SQL to Java provided by an embodiment of the present invention;

[0022] Figure 3 is a flow chart of a method for encapsulating a custom data object provided by an embodiment of the present invention;

[0023] Figure 4 is a flow chart of a method for encapsulating null value variables provided by an embodiment of the present invention;

[0024] Figure 5 is a schematic diagram of a logical operation method of a custom data object provided by an embodiment of the present invention;

[0025] Figure 6 It is a schematic diagram of the structure of a packaging device for converting PL / SQL to Java provided by an embodiment of the present invention;

[0026] Figure 7 It is a schematic diagram of the structure of a logical operation device for a user-defined data object provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0028] In the description of the present invention, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0029] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.

[0030] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0031] First, several nouns involved in the present invention are analyzed:

[0032] Artificial Intelligence (AI): It is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science. AI attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0033] Natural Language Processing (NLP): NLP uses computers to process, understand, and apply human languages ​​(such as Chinese, English, etc.). NLP is a branch of artificial intelligence and an interdisciplinary subject between computer science and linguistics. It is often referred to as computational linguistics. Natural language processing includes grammatical analysis, semantic analysis, and text comprehension. Natural language processing is commonly used in technical fields such as machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information retrieval, information extraction and filtering, text classification and clustering, public opinion analysis, and opinion mining. It involves data mining related to language processing, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computing.

[0034] Information Extraction (NER): A text processing technology that extracts specified types of entity, relationship, event and other factual information from natural language text and forms structured data output. Information extraction is a technology that extracts specific information from text data. Text data is composed of some specific units, such as sentences, paragraphs, and chapters. Text information is composed of some small specific units, such as characters, words, phrases, sentences, paragraphs, or a combination of these specific units. Extracting noun phrases, names, place names, etc. from text data are all text information extraction. Of course, the information extracted by text information extraction technology can be various types of information.

[0035] Procedural SQL (PL / SQL) is a procedural language and a third-generation language. It focuses on processing details like C, C++, Java and other languages, and can be used to implement more complex business logic. It allows SQL data manipulation language and query statements to be included in block-structured and code procedural languages, making PL / SQL a powerful transaction processing language. In terms of Oracle database management, PL / SQL is a procedural language extension of structured query language (SQL). The purpose of PL / SQL is to combine database language and procedural language. The basic unit of PL / SQL is called a block, which consists of three parts: a declaration part, an execution part and an exception handling part. Because PL / SQL allows the mixing of SQL statements and procedural structures, PL / SQL sections and subroutines can be used to combine SQL statements before sending them to the Oracle system for execution. Without PL / SQL, Oracle needs to process SQL statements each time, which will affect traffic flow and increase response time in a network environment. PL / SQL sections are compiled only once and stored in an executable form to reduce response time.

[0036] Structured Query Language (SQL) is a general language used to access relational databases. It belongs to the fourth generation language (4GL). Its execution characteristics are non-procedural, that is, it does not need to specify the specific method and path of execution, but simply calls the corresponding statement to directly obtain the result. Obviously, this language that does not pay attention to any implementation details is extremely convenient for developers. However, some complex business processes require corresponding programs to describe them, in which case 4GL is somewhat powerless. The emergence of PL / SQL is to solve this problem. It is a procedural language and belongs to the third generation language. Like C, C++, Java and other languages, it focuses on processing details and can be used to implement more complex business logic.

[0037] Java is an object-oriented programming language. It not only absorbs the advantages of C++, but also abandons the difficult-to-understand concepts of multiple inheritance and pointers in C++. Therefore, Java has two characteristics: powerful functions and simple and easy to use. As a representative of static object-oriented programming languages, Java has implemented object-oriented theory very well, allowing programmers to perform complex programming with an elegant way of thinking. Java has the characteristics of simplicity, object-oriented, distributed, robust, secure, platform-independent and portable, multi-threaded, and dynamic. Java can be used to write desktop applications, Web applications, distributed systems, and embedded system applications.

[0038] Java basic data types. There are 8 basic data types in Java to store numbers, characters and Boolean values, namely integer types: Byte, Short, Int, Long; floating-point types: Float, Double; character type: Char; Boolean type.

[0039] In the prior art, in PL / SQL, a variable that is only declared but not assigned a value or assigned a null value is still allowed to perform numerical operations, and some system function input parameters also support variables with null values. When converting to Java data, direct type mapping is used, such as converting varchar2 to String, number to long / BigDecimal, and Date to Date. When performing operations, variables of non-Java basic data types cannot be directly operated using expression symbols, and if the variable value is null, a null pointer exception will be caused during the operation. Therefore, for the above situation, the general practice is to encapsulate the expression operation into a group of static methods, and convert the operation between variables from the original symbolic expression to the static method. For example, the addition operation is translated from a+b into OptUtil.add(a,b). When dealing with complex symbolic expression operations, this kind of processing requires a static method call for each operation in the translated statement, which leads to the nesting of a large number of static methods, which is extremely inelegant and creates a great obstacle for developers in reading. The encapsulation of the operation method does not conform to the operation behavior of the variable operation, which undoubtedly increases the burden on developers to understand the code. In addition, a large number of built-in functions also need to add null value processing to the converted Java functions. Without these guarantees, the occurrence of null pointer exceptions during system operation is inevitable.

[0040] There is also a Manifold (manifold) operator overloading improvement plan, which still uses direct type mapping for variable types, and retains the original expression symbols in expression operation translation, without calling static methods to support expression operators for non-Java basic data types. By referencing Manifold's operator overloading function, the system provides support for operators of non-Java basic data types by implementing predefined operator methods of corresponding types. For null value variables participating in operator operations, the null value judgment logic can be processed inside the predefined operator method, avoiding the need to add additional static methods to cut and package expressions. Manifold is essentially a solution that replaces expression operators with operation method calls. By converting the Java source code of the project at compile time, predefined operator methods are woven into and replaced with operator expressions, but the overall source code structure is not affected, which is transparent to developers. In addition, the expression operation in PL / SQL still retains the expressions of all operators when converted to Java code. It is a seamless replacement solution and very elegant. However, this solution has two unsolvable problems in actual use. One is that it relies on a specific JDK (Java Development Kit) and a specific development environment, which is not very friendly to developers. In addition, it cannot be identified and supported in some cases and needs to be converted into complex null value judgment.

[0041] Based on this, the embodiments of the present invention provide an encapsulation method, a logic operation method, an apparatus, a device and a medium, aiming to improve the grammatical accuracy of conversion translation and the correctness of data execution.

[0042] The embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0043] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0044] The encapsulation method and logical operation method provided in the embodiments of the present invention relate to the fields of artificial intelligence and digital medical technology. The encapsulation method and logical operation method provided in the embodiments of the present invention can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the encapsulation method and the logical operation method, etc., but is not limited to the above forms.

[0045] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0046] The embodiments of the present invention are further described below with reference to the accompanying drawings.

[0047] like Figure 1 As shown, Figure 1 It is a schematic diagram of a system architecture platform for a packaging method and a logic operation method provided in an embodiment of the present invention.

[0048] The system architecture platform 100 of the embodiment of the present invention includes one or more processors 110 and a memory 120. Figure 1 In the figure, a processor 110 and a memory 120 are taken as an example.

[0049] The processor 110 and the memory 120 may be connected via a bus or other means. Figure 1 The example of connecting through bus is taken in the following.

[0050] The memory 120, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer executable programs. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 120 may optionally include a memory 120 remotely disposed relative to the processor 110, and these remote memories may be connected to the system architecture platform 100 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0051] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation on the system architecture platform 100, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0052] like Figure 2 As shown, Figure 2 It is a flowchart of a PL / SQL to Java encapsulation method provided by an embodiment of the present invention. The PL / SQL to Java encapsulation method of the embodiment of the present invention includes but is not limited to step S200, step S210, step S220, step S230, step S240 and step S250.

[0053] Step S200, obtaining multiple database data in a PL / SQL database;

[0054] Step S210, screening multiple database data to obtain database data carrying null value variables;

[0055] Step S220, performing null value identification processing on the null value variables in the database data carrying null value variables;

[0056] Step S230, converting all database data to obtain Java data;

[0057] Step S240, identifying and processing the first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulating the Java data to obtain a custom data object;

[0058] Step S250, identifying and processing the database data corresponding to the custom data object, when the database data corresponding to the custom data object carries a null value identifier, selecting a null value instance corresponding to the database data carrying the null value identifier in the custom data object.

[0059] In an embodiment of the present invention, multiple database data in a PL / SQL database are obtained and screened to screen out database data carrying null value variables, and null value identification is performed on the null value variables in the database data carrying null value variables to provide a null value identification for subsequent operations, and all the obtained database data are converted to obtain Java data. In order to identify whether the converted Java data is a Java basic data type or a non-Java basic data type, a first data type of the Java data is identified and processed. When the first data type is a non-Java basic data type, the Java data is encapsulated to obtain a custom data object.

[0060] Exemplarily, direct type mapping is still used when converting database data. When the converted Java data is a non-Java basic data type, that is, the first data type is a non-Java basic data type, such as BigDecimal data is a numeric type data, and Date data is a date type data. This type of data cannot be directly processed using expression symbols for logical operations, and the operation of judging the null value needs to be considered when participating in logical operations. Therefore, custom data objects are used to further encapsulate Java data of non-Java basic data types, such as using custom PaDecimal data objects to replace BigDecimal data, and using custom PaDate data objects to replace Date data. Using custom data objects can realize all logical operation modes, and the judgment of the null value table is built into the logical operation mode, ensuring the grammatical accuracy of the conversion and the correctness of the data execution, while improving the readability of the code and the elegance of the expression statement, greatly improving the user experience.

[0061] In the case of database data carrying a null value identifier, the embodiment of the present invention identifies and processes the database data corresponding to the custom data object. When the database data corresponding to the custom data object carries a null value identifier, the null value instance corresponding to the database data carrying the null value identifier is selected in the custom data object. A global null value instance exists in the custom data object to ensure that the converted Java data is non-null value data, thereby avoiding the situation where a null pointer exception occurs when using Java data, causing the interruption of logical operation processing. The grammatical accuracy of the conversion and the correctness of data execution are ensured, while improving the readability of the code and the elegance of the expression statement, greatly improving the user experience.

[0062] In addition, it should be noted that the above-mentioned null value variables are variables that do not have initialization assignments or variables that are initialized to null values.

[0063] In addition, it should be noted that when the converted Java data is a Java basic data type, that is, the first data type is a Java basic data type, the Java data is used to perform logical operation processing.

[0064] like Figure 3 As shown, Figure 3 It is a flow chart of a method for encapsulating a custom data object provided by an embodiment of the present invention. The method for encapsulating a custom data object in an embodiment of the present invention includes but is not limited to the following steps: step S300, step S310, step S320 and step S330.

[0065] Step S300, obtaining Java data;

[0066] Step S310, identifying and processing the Java data;

[0067] Step S320, when the Java data is numerical data, encapsulate the numerical data to obtain a numerical data object;

[0068] Step S330: When the Java data is date data, encapsulate the date data to obtain a date type data object.

[0069] In an embodiment of the present invention, based on the fact that the Java data after conversion is a non-Java basic data type, the Java data is obtained, and the obtained Java data is identified and processed. When the Java data is identified as numerical data, the numerical data is encapsulated to obtain a numerical data object; when the Java data is identified as date data, the date data is encapsulated to obtain a date data object.

[0070] Exemplarily, when converting database data, direct type mapping is still used. When the converted Java data is a non-Java basic data type, that is, the first data type is a non-Java basic data type, such as BigDecimal type is a numeric type, and Date type is a date type. This type of data cannot be directly processed by expression symbols for logical operations, and the operation of judging null values ​​needs to be considered when participating in logical operations. Therefore, a custom data object is used to further encapsulate Java data of non-Java basic data types. When Java data is numeric data, that is, Java data is BigDecimal type data, a custom PaDecimal type data object is used to replace BigDecimal type data. When Java data is date data, that is, Java data is Date type data, a custom PaDate type data object is used to replace Date type data. All logical operation modes can be realized by using custom data objects, and the judgment table of null values ​​is built into the logical operation mode, which ensures the grammatical accuracy of the conversion and the correctness of data execution, while improving the readability of the code and the elegance of the expression statement, greatly improving the user experience.

[0071] In addition, it should be noted that, in this embodiment, the custom PaDecimal data object is a numerical data object; and the custom PaDate data object is a date data object.

[0072] like Figure 4 As shown, Figure 4 It is a flow chart of a method for encapsulating null value variables provided by an embodiment of the present invention. The method for encapsulating null value variables in an embodiment of the present invention includes but is not limited to the following steps: step S400, step S410, step S420, step S430 and step S440.

[0073] Step S400, identifying and processing the database data corresponding to the custom data object;

[0074] Step S410, when the database data corresponding to the custom data object carries a null value identifier, the database data carrying the null value identifier is identified and processed;

[0075] Step S420, selecting a null value instance corresponding to the database data carrying a null value identifier in the custom data object;

[0076] Step S430, when the database data carrying the null value identifier is numerical data, a numeric null value instance is selected in the custom data object;

[0077] Step S440: When the database data carrying the null value identifier is date data, a date type null value instance is selected in the custom data object.

[0078] Because when Java data is null value data, a null pointer exception will occur when using the Java data, which will cause the logical operation processing to be interrupted, and if the database data before conversion carries null value variables, the converted Java data will be null value data. Therefore, for the case of database data carrying null value variables, the database data is marked as null value in advance in the above embodiment, and a global null value instance is set in the custom data object.

[0079] In an embodiment of the present invention, the database data corresponding to the custom data object is identified and processed; when the database data corresponding to the custom data object carries a null value identifier, the database data carrying the null value identifier is identified and processed; the null value instance corresponding to the database data carrying the null value identifier is selected in the custom data object; when the database data carrying the null value identifier is numerical data, a null value instance of a numerical type is selected in the custom data object; when the database data carrying the null value identifier is date data, a null value instance of a date type is selected in the custom data object. A global null value instance is set in the custom data object, and the null value identifier is identified and processed during conversion to ensure that the converted Java data is non-null value data, thereby avoiding the situation where a null pointer exception occurs when using Java data and causes the interruption of logical operation processing. The grammatical accuracy of the conversion and the correctness of data execution are ensured, while the readability of the code and the elegance of the expression statements are improved, greatly improving the user experience.

[0080] Exemplarily, when the database data carrying a null value identifier is numerical data, the custom data object selected is a custom PaDecimal data object, and a global null value instance is set in the custom PaDecimal data object: PaDecimal.NONE, which is a null value instance of the null type; the null value instance is selected to replace the Java data after the conversion of the database data of the null data type carrying the null value identifier. Similarly, when the database data carrying a null value identifier is date data, the custom data object selected is a custom PaDate data object, and a global null value instance is set in the custom PaDate data object: PaDate.NONE, which is a null value instance of the date type; the null value instance is selected to replace the Java data after the conversion of the database data of the date data type carrying the null value identifier.

[0081] In addition, it should be noted that the above-mentioned null value variables are variables that do not have initialization assignments or variables that are initialized to null values.

[0082] like Figure 5 As shown, Figure 5It is a schematic diagram of the logical operation method of the custom data object provided in an embodiment of the present invention. The logical operation method of the custom data object in the embodiment of the present invention is based on the method proposed in the above embodiment. The logical operation method of the custom data object includes but is not limited to step S500, step S510, step S520 and step S530.

[0083] Step S500, obtaining a custom data object, and inputting the custom data object into a logic operation process;

[0084] Step S510, performing a null value instance recognition process on the user-defined data object input to the logic operation process, and selecting a corresponding processing method according to the result of the null value instance recognition process;

[0085] Step S520, when there are one or more null value instances in the user-defined data object input to the logic operation process, the logic operation process is exited and the null value instance is returned;

[0086] Step S530: When the user-defined data object input for logical operation processing does not have a null value instance, a logical operation processing is performed and a logical operation processing result is returned.

[0087] In the PL / SQL syntax scenario, both numeric data and date data will participate in logical operations. When performing logical operations, as long as there are null value variables in the input parameters of the logical operation, the output result will be a null value.

[0088] Based on this, in an embodiment of the present invention, a custom data object is obtained and input into a logical operation process; a null value instance recognition process is performed on the custom data object input into the logical operation process, and a corresponding processing method is selected according to the result of the null value instance recognition process; when there are one or more null value instances in the custom data object input into the logical operation process, the logical operation process is exited and a null value instance is returned; when there is no null value instance in the custom data object input into the logical operation process, a logical operation process is performed and the result of the logical operation process is returned.

[0089] In addition, in an embodiment of the present invention, the function corresponding to the operation in the above-mentioned logical operation processing adopts a chain call method. For example, s=a.add(b).sub(c). Compared with the traditional method of calling functions to assign variables, e=a.add(b), s=e.sub(c), it not only removes more temporary variables, but also avoids the nested processing of static methods, making the code more compact and easier to read after the expression conversion.

[0090] like Figure 6As shown, an embodiment of the present invention further provides a PL / SQL to Java encapsulation device, which can implement the above PL / SQL to Java encapsulation method, and the encapsulation device includes:

[0091] The data acquisition module 600 is used to acquire multiple database data in the PL / SQL database;

[0092] A null value identification module 610 is used to filter multiple database data to obtain database data with null value variables;

[0093] A null value identification module 620 is used to perform null value identification processing on null value variables in database data carrying null value variables;

[0094] The database data conversion Java data module 630 is used to convert all database data to obtain Java data;

[0095] The Java data identification and encapsulation module 640 is used to identify and process the first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulate the Java data to obtain a custom data object;

[0096] The null value instance identification and encapsulation module 650 is used to identify and process the database data corresponding to the custom data object. When the database data corresponding to the custom data object carries a null value identifier, the null value instance corresponding to the database data carrying the null value identifier is selected in the custom data object.

[0097] It should be noted that the contents of the method embodiments of the present invention are all applicable to the device embodiments. The functions specifically implemented by the device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method, which will not be repeated here.

[0098] like Figure 7 As shown, the embodiment of the present invention also provides a logic operation device for a custom data object, based on Figure 6 The encapsulation device for converting PL / SQL to Java shown can implement the above-mentioned logical operation method of the custom data object. The logical operation device of the custom data object includes:

[0099] A user-defined data object acquisition module 700 is used to acquire a user-defined data object and input the user-defined data object into a logic operation process;

[0100] The null value instance identification module 710 is used to perform null value instance identification processing on the user-defined data object input to the logic operation processing, and select a corresponding processing method according to the null value instance identification processing result;

[0101] The data logic operation module 720 is used to perform logic operation processing.

[0102] It should be noted that the contents of the method embodiments of the present invention are all applicable to the device embodiments. The functions specifically implemented by the device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method, which will not be repeated here.

[0103] In addition, an embodiment of the present invention further provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor.

[0104] The processor and the memory may be connected via a bus or other means.

[0105] The processor may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention;

[0106] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0107] It should be noted that the electronic device in this embodiment can be applied as the PL / SQL to Java encapsulation method and / or the logical operation method of the custom data object in the above embodiment. The electronic device in this embodiment has the same inventive concept as the PL / SQL to Java encapsulation method and / or the logical operation method of the custom data object in the above embodiment. Therefore, these embodiments have the same implementation principles and technical effects, which will not be described in detail here.

[0108] The non-transient software program and instructions required to implement the PL / SQL to Java encapsulation method of the above embodiment and / or the logic operation method of the custom data object of the above embodiment are stored in the memory. When executed by the processor, the PL / SQL to Java encapsulation method of the above embodiment and / or the logic operation method of the custom data object of the above embodiment are executed, for example, the above-described Figure 2 Method steps S200 to S250, Figure 3 Steps S310 to S330 of the method, Figure 4 Steps S400 to S440 of the method, Figure 5 Method steps S500 to S530 in.

[0109] The electronic device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0110] In addition, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. The computer-executable instructions are executed by a processor or a controller, for example, by a processor in the above electronic device embodiment, so that the above processor can execute the PL / SQL conversion Java encapsulation method and / or the logic operation method of the custom data object in the above embodiment, for example, to execute the above-described Figure 2 Steps S200 to S250 of the method, Figure 3 Steps S310 to S330 of the method, Figure 4 Steps S400 to S440 of the method, Figure 5 Method steps S500 to S530 in.

[0111] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0112] It can be understood by those skilled in the art that Figure 1-7 The technical solutions shown in the figure do not constitute a limitation on the embodiments of the present invention, and may include more or fewer steps than those shown in the figure, or a combination of certain steps, or different steps.

[0113] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0114] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0115] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0116] It should be understood that in the present invention, "at least one (item)" refers to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can represent: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0117] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0118] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0119] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0120] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including multiple instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store programs.

[0121] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions without violating the spirit of the present invention. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present invention.

Claims

1. A PL / SQL to Java encapsulation method, characterized in that: The method comprises: Get multiple database data in PL / SQL database; Screening the plurality of database data to obtain database data carrying null value variables; Performing null value identification processing on the null value variables in the database data carrying the null value variables; Convert all the database data to obtain Java data; Identify and process the first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulate the Java data to obtain a custom data object, and when the first data type is a Java basic data type, use the Java data to perform logical operation processing; Identifying and processing the database data corresponding to the custom data object, and when the database data corresponding to the custom data object carries the null value identifier, selecting a null value instance corresponding to the database data carrying the null value identifier in the custom data object; The null value instance corresponding to the database data carrying the null value identifier is selected in the custom data object, including one of the following: When the database data carrying the null value identifier is numerical data, a numeric null value instance is selected in the custom data object; When the database data carrying the null value identifier is date data, a date type null value instance is selected in the custom data object.

2. The encapsulation method for converting PL / SQL to Java according to claim 1, characterized in that: The encapsulating the Java data to obtain a custom data object includes one of the following: When the Java data is numerical data, encapsulating the numerical data to obtain a numerical data object; When the Java data is date data, the date data is encapsulated to obtain a date type data object.

3. A method for logical operation of a custom data object, based on the encapsulation method according to any one of claims 1 to 2, characterized in that: The method comprises: Acquire the user-defined data object, and input the user-defined data object into a logic operation process; The user-defined data object input into the logic operation process is subjected to a null value instance recognition process, and a corresponding processing method is selected according to the result of the null value instance recognition process.

4. The method for logical operation of a user-defined data object according to claim 3, characterized in that: The selecting a corresponding processing method according to the result of the null value instance identification processing includes one of the following: When there are one or more null value instances in the user-defined data object input to the logic operation process, the logic operation process is exited and the null value instance is returned; When the user-defined data object input for logical operation processing does not contain the null value instance, logical operation processing is performed and the logical operation processing result is returned.

5. The method for logical operation of a user-defined data object according to claim 3, characterized in that: The functions corresponding to the operation in the logic operation process are called in a chain manner.

6. A packaging device for converting PL / SQL to Java, characterized in that: The device comprises: Data acquisition module, used to obtain multiple database data in PL / SQL database; A null value identification module, used for screening the plurality of database data to obtain database data carrying null value variables; A null value identification module, used for performing null value identification processing on the null value variables in the database data carrying the null value variables; A database data conversion Java data module is used to convert all the database data to obtain Java data; A Java data identification and encapsulation module, used to identify and process the first data type of the Java data, and when the first data type is a non-Java basic data type, encapsulate the Java data to obtain a custom data object, and when the first data type is a Java basic data type, use the Java data to perform logical operation processing; a null value instance identification and encapsulation module, configured to identify and process the database data corresponding to the custom data object, and when the database data corresponding to the custom data object carries the null value identifier, select the null value instance corresponding to the database data carrying the null value identifier in the custom data object; The null value instance corresponding to the database data carrying the null value identifier is selected in the custom data object, including one of the following: When the database data carrying the null value identifier is numerical data, a numeric null value instance is selected in the custom data object; When the database data carrying the null value identifier is date data, a date type null value instance is selected in the custom data object.

7. A logic operation device for a user-defined data object, based on the encapsulation device according to claim 6, characterized in that: The device comprises: A user-defined data object acquisition module, used to acquire the user-defined data object and input the user-defined data object into a logic operation process; A null value instance recognition module, used to perform null value instance recognition processing on the user-defined data object input into the logic operation processing, and select a corresponding processing method according to the null value instance recognition processing result; The data logic operation module is used to perform the logic operation processing.

8. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the encapsulation method for converting PL / SQL to Java as described in any one of claims 1 to 2 and / or the logical operation method for a custom data object as described in any one of claims 3 to 5 are implemented.

9. A computer-readable storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to implement the PL / SQL conversion Java encapsulation method as described in any one of claims 1 to 2 and / or the logic operation method of the user-defined data object as described in any one of claims 3 to 5 when executing the computer program.

Citation Information

Patent Citations

  • Data processing method and device, computer equipment and storage medium

    CN110297825A

  • Process for generating enterprise java bean components from an SQL database

    US20030055820A1