Q&A

Q1:What are the coding differences between a bean-managed persistence bean and a container-managed persistence bean?
A1: The following are the coding differences between the two types of entity beans:
  • With BMP, the developer is responsible for writing the database access calls. With CMP, the container is responsible for database access.

  • The BMP bean class is not defined as abstract class. The CMP bean class is defined as an abstract class.

  • The persistent state in a BMP is defined as instance variables. In CMP, you write public abstract accessor methods for persistent and relationship fields.

  • A BMP implements all the finder methods in the bean class. A CMP bean class does not implement the finder methods. The queries for the finder methods are specified in the deployment descriptor.

  • A CMP bean class can define select methods, whereas a BMP bean class cannot define select methods.

Q2:What are the similarities and differences between the finder and select methods of a container-managed persistence entity bean?
A2: Both finder and select methods use EJB QL to define the semantics of the method. Finder methods are exposed to the clients in the home interface, whereas select methods are used as internal helper methods of a bean class and are not exposed to the clients. Finder methods can return only EJBObjects or EJBLocalObjects of the same type as the entity bean. Select methods can return EJBObjects, EJBLocalObjects, or persistent field types.
..................Content has been hidden....................

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