Home > Articles > Programming > Java

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

The CMP Entity Bean Dilemma

Application servers built around EJB v1.0 or EJB v1.1 have a limitation that's not always apparent to the evaluator of an EJB application server or an EJB newcomer. For starters, CMP entity bean support was not required for EJB v1.0 compliance. Furthermore, application servers that are compliant with both EJB v1.0 and EJB v1.1 and that support CMP could have a subtle limitation. Very often application servers support mapping of one table to a single CMP entity bean. That is, when specifying which database columns map to what fields of the CMP entity bean, the columns often are capable of being mapped only from a single database table.

A few application servers and third-party products on the market support more sophisticated mappings, but these have been few and far between and often have other limitations that make them undesirable for practical use. Unless you have the luxury of defining your own database schema to which you can map your entity beans (which many pedagogical examples and publications demonstrate), you might be hard-pressed to use CMP entity beans for much of your enterprise data-enabling needs. Very often, you want to map multiple relational database tables (legacy schemas or schemas that otherwise can't be modified) to a single object. Or, perhaps you would like to define your entity object model so that one entity object (such as a shopping cart) contains one or more entity objects of another type (such as shopping cart items). Thus, one or more tables might even map to one or more entity objects.

Such needs are not easily met with CMP entity bean implementations of EJB v1.0 and EJB v1.1. The EJB v2.0 CMP entity bean specification attempts to address some of these problems. Previously, however, many developers simply utilized the BMP entity bean model for creating entity beans. Thus, many of the stated advantages for using CMP entity beans in constructing enterprise applications (such as rapid development) have been moot points in practice because BMP entity beans essentially became the required means for data-enabling enterprise applications.

  • + Share This
  • 🔖 Save To Your Account