CN113190264B - JPA-based automatic data version generation and application device and method - Google Patents

JPA-based automatic data version generation and application device and method Download PDF

Info

Publication number
CN113190264B
CN113190264B CN202110476969.6A CN202110476969A CN113190264B CN 113190264 B CN113190264 B CN 113190264B CN 202110476969 A CN202110476969 A CN 202110476969A CN 113190264 B CN113190264 B CN 113190264B
Authority
CN
China
Prior art keywords
data
version
data version
jpa
generating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110476969.6A
Other languages
Chinese (zh)
Other versions
CN113190264A (en
Inventor
钟俊
郑金新
孙朝辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Tianhao Information Technology Co ltd
Original Assignee
Shanghai Tianhao Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Tianhao Information Technology Co ltd filed Critical Shanghai Tianhao Information Technology Co ltd
Priority to CN202110476969.6A priority Critical patent/CN113190264B/en
Publication of CN113190264A publication Critical patent/CN113190264A/en
Application granted granted Critical
Publication of CN113190264B publication Critical patent/CN113190264B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a JPA-based automatic data version generation and application device and method, which are used for generating and using version codes in an automatic mode, defining unified specifications of data versions and ensuring unified structure. The device and the method for generating and applying the automation data version based on the JPA can unify the use of the data version, reduce the code redundancy, improve the code readability and the functional accuracy, and improve the understanding capability of development engineers on the concept of the data version.

Description

JPA-based automatic data version generation and application device and method
Technical Field
The invention relates to the field of databases, in particular to a JPA-based automatic data version generation and application device and method with good code readability and functional accuracy.
Background
JPA is also called Spring data JPA, is a JAVA persistent layer API, and is used for describing the mapping relation of an object-relation table and persisting entity objects in a database in the running period. The data version is designed so that when the database manipulates data, it is desirable to keep the data before the manipulation, and it is possible to see what data is before the manipulation and what data is after the manipulation. For such a requirement, it may be implemented using retention history data or using version. In the prior art, the code encoding of the data version is manually carried out in a mode of usually using mybatis, however, the understanding of the data version by developers is inconsistent, and the implementation modes cannot be unified; the data version codes are mixed together with the common codes, so that errors are easy to occur; the data version and the data entity need to be respectively inquired and used, and the code readability and maintainability are poor.
Accordingly, there is a need for an improvement that overcomes the shortcomings of the prior art.
Disclosure of Invention
The invention aims to solve the problems in the prior art and provides a device and a method for generating and using a data version code in an automatic mode, defining unified specifications of the data version and ensuring the automatic data version generation and application based on JPA with unified structure.
The technical scheme of the invention is as follows:
the invention provides a JPA-based automatic data version generation and application method, which comprises the following steps:
s1, establishing data version configuration: configuring the data version in a mode of creating notes, and configuring the data entity according to requirements;
s2, establishing a data entity: establishing data entities in all the systems, and writing data version configuration for the data entities and data attributes;
s3, generating a data version CLASS file: scanning the data entity with the data version configuration in the step S2, and automatically generating a CLASS file corresponding to the data version through a JAVA reflection mechanism and file operation; according to whether the association is configured, automatically generating the cascade connection of the associated data versions;
s4, applying the data version; the data version configuration automatically performs deletion and correction on the data of the data version according to the data operation of the user, and records the version data filled by the user each time.
The step S3 and the step S4 also comprise the following steps: establishing a proxy operation object of a data version through a factory mode based on a JPA technology; and when the application is performed, the proxy operation object operates the CLASS corresponding to the generated data version to obtain the content of the data version and perform related application.
As a preferred technical solution, the creating of the annotation in the step S1 requires annotation parsing by a tool class to find the specified data entity and data attribute.
As a preferable technical solution, the data entity in step S2 is set under the com.
As a preferable technical scheme, the step S3 includes an exception handling mechanism by generating a data version CLASS file and the step S4 by applying the data version, and the exception handling mechanism includes an exception operation including version exception, version CLASS not found exception, no data entity exception, and associated attribute not found exception.
As a preferable technical solution, the data version CLASS file generated in the step S3 is consistent with the file directory of the original data entity.
As a further preferable technical solution, the file name prefix of the data version CLASS file is consistent with the data entity file name; the data version CLASS file ends with DV; the data version CLASS file content comprises all the content in the data version configuration, and unified content related to the data version is added.
In addition, the invention also provides a device applied to the JPA-based automatic data version generation and application method, which comprises the following steps: the configuration module is used for configuring the data entity and/or the data attribute to generate a data version or a null value coverage; the generation module is used for performing CLASS generation of a data version on the content of the configuration scanning during system initialization; and the application module is used for carrying out data operation on the data version through the JPA.
As a preferable technical scheme, the system further comprises an association module, wherein the association module is used for automatically generating associated data versions according to association relations of different data entities.
As a further preferable technical scheme, the configuration module, the generation module, the application module and the association module are corresponding computer readable instructions, and the computer readable instructions are stored in a computer readable medium.
According to the JPA-based automatic data version generation and application device and method, the generation and the use of version codes are carried out in an automatic mode, unified specifications of data versions are defined, and unified structure is guaranteed. The device and the method for generating and applying the automation data version based on the JPA can unify the use of the data version, reduce the code redundancy, improve the code readability and the functional accuracy, and improve the understanding capability of development engineers on the concept of the data version.
Drawings
FIG. 1 is a block flow diagram of an embodiment of a method for JPA-based automated data version generation and application;
fig. 2 is a block diagram of an embodiment of an apparatus for JPA-based automated data version generation and application according to the present invention.
Description of the embodiments
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, the "plurality" generally includes at least two, but does not exclude the case of at least one.
It should be understood that the term "and/or" as used herein is merely one relationship describing the association of the associated objects, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a product or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such product or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a commodity or system comprising such elements.
As shown in fig. 1, the invention discloses a JPA-based automatic data version generation and application method, which comprises the following steps:
s1, establishing data version configuration: by configuring the data version in a manner that creates annotations, the data entity is configured according to requirements. I.e. providing a configuration of the data version of DvEntity, dvField, dvIgnoreNullFiled, dvReField etc. by creating annotations.
S2, establishing a data entity: establishing data entities in all the systems, and writing data version configuration for the data entities and data attributes;
s3, generating a data version CLASS file: scanning the data entity with the data version configuration in the step S2, and automatically generating a CLASS file corresponding to the data version through a JAVA reflection mechanism and file operation; and according to whether the association is configured, automatically generating the cascade connection of the associated data versions. When the system is initialized, the scanning configuration package generates all data entities with data version configuration, and the CLASS corresponding to the data version is automatically generated through a JAVA reflection mechanism and file operation. And according to whether the association is configured, automatically generating the associated data version in a cascading way, and ensuring the consistency of each level of associated version.
S4, applying the data version; the data version configuration automatically performs deletion and correction on the data of the data version according to the data operation of the user, ensures the data consistency with the data entity, and records the version data filled by the user each time to achieve the effect of recording history.
In practical application, the steps between the step S3 and the step S4 further include the following steps: based on the JPA technology, a proxy operation object of a data version is established through a factory mode, and when the proxy operation object is applied, the proxy operation object operates the CLASS corresponding to the generated data version to obtain the content of the data version and perform related application.
For implementation, creating the annotation in step S1 requires annotation parsing by tool classes to find the specified data entities and data attributes as a preferred approach.
For the purpose of function implementation and convenient management, the data entity in step S2 is set under the com.
To guarantee the functional implementation, an exception handling mechanism needs to be added. And step S3, generating a data version CLASS file and step S4, and applying the data version, wherein the exception handling mechanism comprises an exception operation, the exception operation comprises version exception, version CLASS does not find exception, no data entity exception and associated attribute does not find exception. That is, when the application is generated in steps S3 and S4, the abnormal operations such as version abnormality, version CLASS not finding abnormality, no data entity abnormality, association attribute not finding abnormality and the like are defined for performing an abnormality processing mechanism for the generation and application operations.
The file output in the step S3 is a CLASS file and is consistent with the file directory of the original data entity so as to ensure the corresponding relation between the data entity and the data version. In order to further ensure unified correspondence between data entities and data versions, the file name prefix of the data version CLASS file is consistent with the file name of the data entity; the data version CLASS file ends with DV; the data version CLASS file content comprises all the content in the data version configuration, and unified content related to the data version is added.
Fig. 2 shows an apparatus for applying the above JPA-based automated data version generation and application method according to the present invention, including:
and the configuration module is used for configuring the data entity and/or the data attribute to generate a data version or null value coverage. That is, the configuration module is configured to configure whether the data entity generates the data version, whether the data attribute generates the data version, and whether the data attribute generates the null value coverage.
And the generation module is used for carrying out CLASS generation of the data version on the content of the configuration scanning during system initialization. The generation module automatically generates the CLASS of the data version in an annotating mode, abandons the mode of manually writing a large number of codes, reduces redundancy, improves code readability and defines the writing specification of the data version.
And the application module is used for carrying out data operation on the data version through the JPA. The application module is used for carrying out data operations such as saving, updating, deleting and the like on the data version. And the application module reads the information of the data entity and the data version through the interface, and obtains a version comparison result for interface display.
In practical application, because the association relationship exists between the data entities, an association module can be set according to practical requirements, and the association module is used for automatically generating an association data version according to the association relationship of different data entities.
In application, the configuration module, the generation module, the application module and the association module are corresponding computer readable instructions, and the computer readable instructions are used for executing related operations to realize related functions, and the computer readable instructions are stored in a computer readable medium.
According to the JPA-based automatic data version generation and application device and method, the generation and the use of version codes are carried out in an automatic mode, unified specifications of data versions are defined, and unified structure is guaranteed. The device and the method for generating and applying the automation data version based on the JPA can unify the use of the data version, reduce the code redundancy, improve the code readability and the functional accuracy, and improve the understanding capability of development engineers on the concept of the data version.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Equivalent changes and modifications of the invention are intended to fall within the scope of the present invention.

Claims (9)

1. A JPA-based automatic data version generation and application method is characterized in that: the method comprises the following steps:
s1, establishing data version configuration: configuring the data version in a mode of creating notes, and configuring the data entity according to requirements;
s2, establishing a data entity: establishing data entities in all the systems, and writing data version configuration for the data entities and data attributes;
s3, generating a data version CLASS file: scanning the data entity with the data version configuration in the step S2, and automatically generating a CLASS file corresponding to the data version through a JAVA reflection mechanism and file operation; according to whether the association is configured, automatically generating the cascade connection of the associated data versions;
s4, applying the data version; the data version configuration automatically performs deletion and correction on the data of the data version according to the data operation of the user, and records the version data filled by the user each time;
the step S3 and the step S4 also comprise the following steps: establishing a proxy operation object of a data version through a factory mode based on a JPA technology; and when the application is performed, the proxy operation object operates the CLASS corresponding to the generated data version to obtain the content of the data version and perform related application.
2. The method for generating and applying an automated data version based on JPA according to claim 1, wherein: the creating of the annotation in step S1 requires annotation parsing by tool class to find the specified data entity and data attribute.
3. The method for generating and applying an automated data version based on JPA according to claim 1, wherein: and the data entity in the step S2 is established under the com.telehot directory structure.
4. The method for generating and applying an automated data version based on JPA according to claim 1, wherein: and step S3, generating a data version CLASS file and step S4, and applying the data version, wherein the exception handling mechanism comprises an exception operation, the exception operation comprises version exception, version CLASS does not find exception, no data entity exception and associated attribute does not find exception.
5. The method for generating and applying an automated data version based on JPA according to claim 1, wherein: and the data version CLASS file generated in the step S3 is consistent with the file directory of the original data entity.
6. The method for generating and applying an automated data version based on JPA according to claim 5, wherein: the file name prefix of the data version CLASS file is consistent with the file name of the data entity; the data version CLASS file ends with DV; the data version CLASS file content comprises all the content in the data version configuration, and unified content related to the data version is added.
7. An apparatus for applying the JPA-based automated data version generation and application method of any one of claims 1 to 6, comprising:
the configuration module is used for configuring the data entity and/or the data attribute to generate a data version or a null value coverage;
the generation module is used for performing CLASS generation of a data version on the content of the configuration scanning during system initialization;
and the application module is used for carrying out data operation on the data version through the JPA.
8. The apparatus for JPA-based automated data version generation and application of claim 7, wherein: the system also comprises an association module, wherein the association module is used for automatically generating associated data versions according to association relations of different data entities.
9. The apparatus for JPA-based automated data version generation and application of claim 8, wherein: the configuration module, the generation module, the application module and the association module are corresponding computer readable instructions, and the computer readable instructions are stored in a computer readable medium.
CN202110476969.6A 2021-04-29 2021-04-29 JPA-based automatic data version generation and application device and method Active CN113190264B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110476969.6A CN113190264B (en) 2021-04-29 2021-04-29 JPA-based automatic data version generation and application device and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110476969.6A CN113190264B (en) 2021-04-29 2021-04-29 JPA-based automatic data version generation and application device and method

Publications (2)

Publication Number Publication Date
CN113190264A CN113190264A (en) 2021-07-30
CN113190264B true CN113190264B (en) 2024-02-23

Family

ID=76980883

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110476969.6A Active CN113190264B (en) 2021-04-29 2021-04-29 JPA-based automatic data version generation and application device and method

Country Status (1)

Country Link
CN (1) CN113190264B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101809571A (en) * 2007-09-25 2010-08-18 阿玛得斯两合公司 A method and apparatus for version management of a data entity
CN103226478A (en) * 2013-05-22 2013-07-31 北京金和软件股份有限公司 Method for automatically generating and using code
CN106648587A (en) * 2016-09-28 2017-05-10 福州宇嘉软件科技有限公司 Annotation-based Web application code generation method
CN106874388A (en) * 2017-01-11 2017-06-20 中科院微电子研究所昆山分所 A kind of heterogeneous system data cascade operation method for auto constructing based on relevant database
CN107357942A (en) * 2017-09-04 2017-11-17 山东达创网络科技股份有限公司 A kind of source code auxiliary Core Generator and its generation method
CN110825369A (en) * 2019-11-07 2020-02-21 四川长虹电器股份有限公司 Method for automatically generating codes based on java language
CN111736813A (en) * 2020-06-24 2020-10-02 深圳前海微众银行股份有限公司 JPA code generation method and device, terminal equipment and storage medium
WO2020232569A1 (en) * 2019-05-17 2020-11-26 环球雅途集团有限公司 Database access layer representation method and device
CN112000320A (en) * 2020-08-27 2020-11-27 中国平安财产保险股份有限公司 Automatic code generation method, device, equipment and storage medium
CN112379871A (en) * 2020-11-17 2021-02-19 广州小鹏汽车科技有限公司 Data processing method and device
CN112463135A (en) * 2020-12-11 2021-03-09 中国人寿保险股份有限公司 Code generation method, code generator, electronic device, and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7020660B2 (en) * 2001-06-29 2006-03-28 Siemens Medical Solutions Health Services Corp. Data object generator and method of use
US11175910B2 (en) * 2015-12-22 2021-11-16 Opera Solutions Usa, Llc System and method for code and data versioning in computerized data modeling and analysis

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101809571A (en) * 2007-09-25 2010-08-18 阿玛得斯两合公司 A method and apparatus for version management of a data entity
CN103226478A (en) * 2013-05-22 2013-07-31 北京金和软件股份有限公司 Method for automatically generating and using code
CN106648587A (en) * 2016-09-28 2017-05-10 福州宇嘉软件科技有限公司 Annotation-based Web application code generation method
CN106874388A (en) * 2017-01-11 2017-06-20 中科院微电子研究所昆山分所 A kind of heterogeneous system data cascade operation method for auto constructing based on relevant database
CN107357942A (en) * 2017-09-04 2017-11-17 山东达创网络科技股份有限公司 A kind of source code auxiliary Core Generator and its generation method
WO2020232569A1 (en) * 2019-05-17 2020-11-26 环球雅途集团有限公司 Database access layer representation method and device
CN110825369A (en) * 2019-11-07 2020-02-21 四川长虹电器股份有限公司 Method for automatically generating codes based on java language
CN111736813A (en) * 2020-06-24 2020-10-02 深圳前海微众银行股份有限公司 JPA code generation method and device, terminal equipment and storage medium
CN112000320A (en) * 2020-08-27 2020-11-27 中国平安财产保险股份有限公司 Automatic code generation method, device, equipment and storage medium
CN112379871A (en) * 2020-11-17 2021-02-19 广州小鹏汽车科技有限公司 Data processing method and device
CN112463135A (en) * 2020-12-11 2021-03-09 中国人寿保险股份有限公司 Code generation method, code generator, electronic device, and storage medium

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
Spring环境下的敏捷ORM框架设计与实现;伍文彬;软件导刊(第05期);134-136 *
utomatic code generation by model transformation from sequence diagram of system’s internal behavior;EL BEGGAR Omar等;《International Journal of Computer and Information Technology 》;20121130;129-146 *
一种基于源码分析和代码生成的ORM开发工具——EasyPersist;瞿华;《电脑知识与技术》;20160819;83-86 *
基于J2EE的企业信息管理系统基础框架的设计与实现;胡宇;《中国优秀硕士学位论文全文数据库 信息科技辑》;20180215;I138-552 *
基于标注和反射机制的通用JavaBean持久化工具类;檀明等;微电子学与计算机(第04期);29-32、37 *
孙更新等.《Java程序开发大全 —基于MyEclipse平台+Struts+Hibernate+Spring主流框架开发》.中国铁道出版社,2010,(第1版),234-237. *

Also Published As

Publication number Publication date
CN113190264A (en) 2021-07-30

Similar Documents

Publication Publication Date Title
US5327559A (en) Remote and batch processing in an object oriented programming system
US6349404B1 (en) Object-oriented repository, a system and method for reusing existing host-based application assets for the development of business-centric applications
TWI412945B (en) Retrieving and persisting objects from/to relational databases
US7424702B1 (en) Data integration techniques for use in enterprise architecture modeling
EP0978061B1 (en) Object graph editing context and methods of use
US6990656B2 (en) Dynamic metabase store
US5442779A (en) System and method for enabling an interpreted programming language to be executed in a database management system environment
US8086642B2 (en) Apparatus, system, and method for processing hierarchical data in disparate data repositories
CN108762743B (en) Data table operation code generation method and device
CN112287009A (en) Interface calling and interface data warehousing method, device, equipment and storage medium
US20070073675A1 (en) Database query translation
US8214799B2 (en) Providing information to an isolated hosted object via system-created variable objects
CN112235311B (en) OVSDB client code automatic generation method, system, device and medium
US20060129985A1 (en) Development and execution platform
US6763361B1 (en) Object-oriented database abstraction and statement generation
US7434227B2 (en) Portable business information content and management system
US6917939B1 (en) Method and apparatus for configurable mapping between data stores and data structures and a generalized client data model using heterogeneous, specialized storage
CN111488144B (en) Data processing method and device
CN113190264B (en) JPA-based automatic data version generation and application device and method
US7283994B2 (en) Merging of products into a database
US6105073A (en) Method for packing/unpacking C operations to/from RPC compatible format using the RPC protocol to operate remotely with an object-oriented repository
CN111222015B (en) Method for generating document by heterogeneous XML mapping
US7587505B2 (en) Data communication method, data communication system, and program
US7890963B2 (en) Vector replacement method
US7305583B2 (en) Command initiated logical dumping facility

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant