Hi

I am using JSP (client) and BMP Entity beans (for mysql db) in my
application. I am having a few problems in terms of performance.

1. When I call homeObject.findAll() for the first time, ejbLoad() is invoked
for every row in the database. I know this only happens once so I can
tolerate this but I am open to suggestions.

2. Once the entity beans are loaded, I call
homeObject.findByPrimaryKey().getSomeAttribute(). This calls ejbStore() for
every row in the database as well. This is not acceptable as the EJB is
performing "UPDATE" * number of rows in DB.

I tried to solve this by implementing a stateful session bean acts a middle
layer between JSP and entity beans. However, the problem still exists

My session bean code:

public class PubcompanyManagerBean implements SessionBean{

  private SessionContext context;

  private PubCompany pubcompany;
  private PubCompanyHome pubcompanyhome;

  public void ejbCreate() throws NamingException, RemoteException {}

  public void ejbRemove() {}
  public void ejbActivate() {}
  public void ejbPassivate() {}
  public void setSessionContext(SessionContext sc) {
    context = sc;
  }

  // Business logic methods
  public Collection getAllPubCompanies() throws NamingException,
RemoteException, FinderException {
    Context context = new InitialContext();
    pubcompanyhome = (PubCompanyHome)PortableRemoteObject.narrow(
      context.lookup("java:comp/env/crm/PubCompany"), PubCompanyHome.class);
    Collection companyList = pubcompanyhome.findAll();
    return companyList;
  }

  public PubCompany getPubCompany(String companyid) throws NamingException,
RemoteException, FinderException {
    Context context = new InitialContext();
    pubcompanyhome = (PubCompanyHome)PortableRemoteObject.narrow(
      context.lookup("java:comp/env/crm/PubCompany"), PubCompanyHome.class);
    pubcompany = pubcompanyhome.findByPrimaryKey(companyid);
    return pubcompany;
  }
}


Thanks in advance,

Tim


Reply via email to