EJB Projects

EJB Project 1

EJB Examples


To Implementing the Entity Bean Home Interface:

Home interface is a primarily used for retrieving the bean reference, on which the client can request business methods.

Previous Home Next
  1. Local Home interface extends javax.ejb.EJBLocalHome. this packages are using in interfaces
  2. Remote Home interface extends javax.ejb.EJBHome.this packages are using in interfaces.

Home interface must contained a create method, and it'sthe client invoking to create the bean instance. The Entity bean can have zero or more create methods, and Each with its own defined parameters. it's all entity beans must define one or more finder methods, where at least one is a findByPrimaryKey method. Optionally, you can develop other finder methods, this packages are using in interfaces for the bean.

The Creation and retrieval methods, and you can provide home interface business methods within the home interface. The functionality within these methods cannot access data of a particular entity object.

Instead, the purpose of these methods is to provide a way to retrieve information that is not related to a single entity bean instance. When the client invokes any home interface business method, an entity bean is removed from the pool to service the request. Thus, this method can be used to perform operations on general information related to the bean.

Our employee example provides the local home interface with a create, find By Primary Key, find All, and calcSalary methods. The calcSalary method is a home interface business method that calculates the sum of all employee salaries. It does not access the information of a particular employee, but performs a SQL inquiry against the database for all employees.

package employee;
import javax.ejb.*;
import java.rmi.*;
public interface employeelocalhome extends EJBLocalHome
  public employeelocal create(Integer empNo) throws CreateException;

  // Find an existing employee

  public employeelocal findByPrimaryKey (Integer empNo) throws FinderException;

  //Find all employees

  public Collection findAll() throws FinderException;

  //Calculate the Salaries of all employees

  public float calcSalary() throws Exception;
Previous Home Next