Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the trap of Java Persistence API?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What is the trap of Java Persistence API? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

JPA is an important part of Java EE 5, and its adoption greatly simplifies the use of Entity Bean. But JPA has an obvious drawback, that is, unprincipled adoption of JPA, it is possible to migrate the database structure to the code of your application. This will cause trouble for the maintenance and upgrade of the application.

The "unprincipled use of JPA" by the editor mainly refers to the definition of the relationship between Entity Bean through Annotation. The relationships of these data entities, such as one-to-many, one-to-one, many-to-one, many-to-many, and associated operations (cascade), are clearly database concepts. In order to achieve the purpose of ORM, JPA has to define this relationship in Entity source code.

To a large extent, the structure and design of the database are migrated to the application. There are the following questions:

First, the poor readability of the application source code the complexity of the database structure depends almost entirely on the business logic of the application. If the business logic is complex, it will be difficult to define the relationship of the Entity Bean. As you can imagine, the readability of the code will be very poor.

Second, the maintainability of the application is poor. Once the database structure changes due to business requirements, these relationships will need to be redefined.

Third, it is almost unrealistic to define more complex database structure relationships, which is also the limitation of ORM itself. Porting the database structure to the application itself is a mistake. Relational databases mainly focus on the word "relational", because databases are concerned with data and its integrity (Data). On the other hand, the application program adopts the development means of OOP, and is concerned about the Operation of each "Object" within the system. Data is the state of the application; actions are the business logic of the application. State and action are the two major elements of an application, both of which are indispensable. While ORM tries to ignore the state and raise the action, do not know that the final result of the "action" should be implemented in the change of the "state".

The answer to the question about the trap of Java Persistence API is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report