Java persistence API (JPA) traps

Source: Internet
Author: User

JPA is an important part of Java ee 5. It greatly simplifies the use of entity beans. But one obvious drawback of JPA is that it is possible to port the database structure to your application without using JPA in principle.ProgramOfCode. This will cause trouble for application maintenance and upgrade.

In this article, "using JPA without principle" mainly refers to defining the relationship between entity beans through annotation. The relationships between these data entities, such as one-to-many, one-to-one, many-to-one, and many-to-many and association operations (cascade), are clearly the concept of databases. To achieve the purpose of ORM, JPA hasSource code.

To a large extent, this migrates the structure and design of the database to the application. This has the following problems:

1. The source code of an application is less readable than the complexity of the database structure. It depends almost entirely on the business logic of the application. If the business logic is complex, it is difficult to define the relationship between entity beans. As you can imagine, the readability of the code will be poor.

2. Poor maintainability of applications once the database structure changes due to business needs, these relationships will need to be redefined.

Iii. Defining complex database structure relationships is almost unrealistic, which is also a limitation of the ORM itself. Porting a database structure to an application is an error. Relational databases are mainly written in the word "relationship", because the database is concerned with data and its integrity (data ). Applications adopt OOP development methods and focus on the operation of "objects" in the system ). Data is the state of an application, and action is the business logic of the application. Status and action are two major elements that constitute an application. While ORM tries to ignore the status and raise the action, it doesn't know that the final result of the "Action" should be implemented in the "State" change. Why is object database management system (odbms) not popular?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.