Chapter 7. Entity Beans with CMP

Topics in This Chapter

  • Container-Managed Persistence

  • Entity Bean Relationships and Navigability

  • Entity Bean CMP and CMR Fields

  • EJB Query Language

  • Finder/Select Queries

  • Local Objects

  • Session Facade Pattern

Now that we've slugged through the swamp of BMP, tackling dirty flags, DAOs, and the underlying workings of finder methods, we're ready to take on the challenge of Container-Managed Persistence. With CMP, the bean developer does not write the database access code that entity beans use to insert, select, update, and delete records. If business methods modify persistent variables, the CMP mechanism automatically records these changes in the underlying datastore. And, database independent persistent mechanisms are no longer necessary. Instead, the container provides these services. As an added bonus, the source of your bean implementation class shrinks dramatically with CMP. All you have to do is figure out how to tell the container what you want. Simple enough? Not quite. A big part of CMP is communicating to the container how you want your entity bean to behave under the watchful eye of the application server and its EJB container.

In this chapter we'll explore writing entity beans using CMP, including how to specify an entity bean's persistent fields, its relationship fields, customized finder methods, and select methods. We'll also expand the CustomerSession EJB Session Facade bean from the previous chapter. Not only will this approach provide an appealing client interface to our Customer EJB, but we'll also describe the related Order EJB and LineItem EJB. All three entity beans will use CMP in their implementations and have the CustomerSession Facade as the remote client access mechanism.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.54.7