Entitybean: Provides robust data persistence. The bean container handles most of the data integrity, resource management, and concurrency features, allowing developers to focus on business logic and data processing, rather than these low-level details. When using bean-managed persistence (Bean Managed persistence,bmp) entity beans, developers write persistent code and the container determines when the code executes. When using container-managed persistence (Container Managed persistence,cmp) entity beans, the container generates persistent code and manages the persistence logic.
JDO: only provides object-oriented persistent data storage. Developers use POJO (unformatted normal Java objects, plain ordinary Java object) to mount and store persistent data.
Entitybean mainly has the following advantages:
1, standardization. The EJB specification defines a set of vendor-independent interfaces that Java EE vendors can implement to support entity beans. This standardization allows for the development of best practices and shortens the adaptation period when hiring new developers. Because the basic component architecture and design patterns are known to all, it is easy to find qualified people to implement them.
2, container Management services. As we discussed in the first two articles of this series, EJB container-managed services provide great benefits for dealing with enterprise functions such as security, transaction processing, connection pooling, and resource management.
3, transparent durability. In CMP, the container can automatically manage persistent semantics. While using a BMP entity bean, the developer must write the persistence logic, and the container determines when the method defined by the developer is invoked. When using both CMP and BMP entity beans, the container determines when the state of the bean is persisted and how to ensure data integrity and concurrency with the underlying data store.
4, transaction support. Developers have granular control over CMP transactions (containment level, transaction requirements, and the inclusion/exclusion of methods), with fine-grained control over BMP transactions, which are implemented programmatically with transaction semantics in bean code. In both cases, the container manages the transaction and determines whether the given transaction should be committed.
5, based on the components of the design. Entity beans are designed to contain components that are configured with deployment descriptors and can be deployed to any Java EE application Server without changing any code.
In summary, the advantage of entity beans is that they can benefit from standardization and industry best practices, simplifying some of the complexities of enterprise development. The disadvantages are:
1, the design is complex.
2. Because of the complexity of enterprise beans and, in particular, entity beans, one iteration (Design/build/test/integrate/test/deploy) may take much longer than other Java persistence solutions.
3, the response time is not ideal.
4, resource occupancy is too high, will always consume a lot of server resources.
The advantages of JDO compared to entity beans are:
1, simple design.
2. Fine-grained control allows developers to fully control the entire persistence process, including caching, persistence, concurrency, and synchronization.
3, Simple coding. The JDO architecture hides low-level persistence details for developers.
4. JDO does not only make Java objects persistent; it also transparently handles the persistence of the entire graph of related objects. Therefore, when an instance is persisted, any internal references it maintains to other object instances are also persisted (unless they have been declared transient). JDO also stores the complete information of the type hierarchy and implements the request based on the type (parent class and interface) rather than on the specific local type of the persistent instance.