EJB design: EJB 2.0 CMP EJB's

  1. EJB 2.0 CMP EJB's (2 messages)

    Why do you not include the datafields, ( object attributes ) in the source for the actual bean? I've seen examples where there are get and set methods and other methods that access the datafields, but the actaul fields aren't declared. Where do I declare them then,since with out them my bean sources won't compile?

    Threaded Messages (2)

  2. EJB 2.0 CMP EJB's[ Go to top ]

    I think in EJB 2.0 you *don't* declare the persistent fields. They are owned by the container - you have no direct access to them. You can only access persisted fields by the get/set methods.


  3. EJB 2.0 CMP EJB's[ Go to top ]

    You don't declare any of the persistent fields. Not the CMP fields, nor the CMR fields.
    In EJB2.0 you define an "abstract persistence schema", which means you describe the persistent schema of your bean in abstract terms. You never provide concrete implementations. It is up to the Persistence Manager (currently a part of the container) to materialize this schema.
    By defining the persistent schema in such a way (rather than EJB1.X's field based approach), EJB2.0 allows a much larger variety of possible implementation options. The PM can use lazy loading, dirty reads, and a bunch of other strategies. What this means for you is a higher optimization level for your beans.
    Just to be clear on how this is performed: the PM subclasses your class and provides concrete implementations for the abstract accessor methods. One classical option is to have all the data cached and synchronized during ejbStore/ejbLoad. The resulting class (PM generated) will be very similar to the EJB class as written with EJB1.X. However, the accessors can also load data on-demand, etc.