Introduction to Entity Beans 133 method is called, (Web hosting isp)

Introduction to Entity Beans 133 method is called, the ejbCreate() method is responsible for creating database data. Similarly, when a bean-managed persistent entity bean s ejbRemove() method is called, the ejbRemove() method is responsible for removing database data. If container-managed persistence is used, the container will modify the database for you, and you can leave these methods empty of data access logic. Let s look at this in more detail. Understanding How Entity Beans Are Created and Destroyed In EJB, remember that clients do not directly invoke beans they invoke an EJB object proxy. The EJB object is generated through the home object. Therefore, for each ejbCreate() method signature you define in your bean, you must define a corresponding create() method in the home interface. The client calls the home object s create() method, which delegates to your bean s ejbCreate() method. For example, let s say you have a bank account entity bean class called AccountBean, with a remote interface Account, home interface AccountHome, and primary key class AccountPK. Given the following ejbCreate() method in AccountBean: public AccountPK ejbCreate(String accountID, String owner) throws… you must have this create() method in your home interface (notice there is no ejb prefix): public Account create(String accountID, String owner) throws … Notice that there are two different return values here. The bean instance returns a primary key (AccountPK), while the home object returns an EJB object (Account). This makes sense the bean returns a primary key to the container (that is, to the home object) so that the container can identify the bean. Once the home object has this primary key, it can generate an EJB object and return that to the client. We show this process more rigorously with the sequence diagram in Figure 6.6.
Welcome to web hosting for all of you from India.Our recommendation is Web Hosting India.

Leave a Reply