
|
|
Enterprise JavaBeansTM 2.0 Specification(Text Source: http://java.sun.com) Container-Managed Persistence (CMP) -- Simplifying and Expediting Application DevelopmentThe EJB architecture greatly simplifies the connection between the application and the database tiers. The EJB 2.0 specification takes this benefit to the next level by allowing developers to develop portable applications that are database-independent and free of database access code. Frequently, application developers don't have access to the physical database schema when building their applications. Sometimes this is for security reasons. Sometimes it is because the physical schema has not been designed or finalized. Other times, application developers don't want to know the entire physical database schema, especially when a large, complex database is shared between many less-complex applications. CMP can be used to isolate the application developer from the physical database schema. This done by creating an abstract schema that matches the needs of the current application, and using CMP to map between the abstract and physical schemas. This technique allows better partitioning of effort in the development staff, requires less code to be written and maintained, and provides faster time to market. Additionally, the use of CMP ensures that applications are portable in the event of vendor or schema changes. EJB 1.1 provided a simple CMP facility that provided some of these benefits. However, feedback from the development community indicated that this facility was too limited, both in the data modeling capability and in the mechanism used to define the mapping of the CMP bean to the database schema. EJB 2.0 extends CMP to address these concerns. A far more robust modeling capability is added, with support for declarative management of relationships between entity EJBs. Developers no longer need to re-establish relationships between the various beans that make up their application -- the container will restore the connections automatically as beans are loaded, allowing bean developers to navigate between beans much as they would between any standard Java objects. EJB 2.0 also introduces for the first time a portable query language, based on the abstract schema, not on the more complex database schema. This provides a database and vendor-independent way to find entity beans at run time, based on a wide variety of search criteria. What does all this mean? Developers can focus on creating business logic, while the EJB container automatically manages the database access for their applications. In the context of our web retail example, the benefit of CMP is realized in many places. For example, there are many related database updates that need to occur in response to a purchase, in the inventory database, the purchase order database, the customer database and so on. To complicate the situation, some of these databases may be relational, while others may be customer relationship management systems or other enterprise applications. Declarative relationships between enterprise beans enable the developer to specify the relationship between customers and purchase orders, once. He doesn't need to understand the storage technologies, or foreign key relationships, or to manually write the database access code to facilitate all these database updates. This increases competitiveness of the web retail site by enabling the development team to attain faster time to market, not only for new applications, but also for application updates that are required to adapt to frequently changing market needs. The resulting application will also be smaller in code-base, hence easier to maintain, and portable across application servers and databases systems from different vendors, allowing the selection of different vendors as business needs change.
|