Tim,
As I am not sure of the exact nature of your entity beans, I can't give
you any detailed suggestions, but many people impement a 'dirty' flag in
their code.
eg:
void setName(String name)
{
dirty=true;
this.name = name;
}
ejbStore()
{
if (!dirty)
return;
else
{
doUpdate();
dirty=false;
}
}
This limits the number of updates that you are doing.
I assume that you have a very good reason for using BMP, but I would
suggest that you use CMP where possible. The performance benefits are
quite large.
Cheers,
Scott
Tim Kang wrote:
> 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
>
>
>
>
--
Scott Farquhar :: [EMAIL PROTECTED]
Atlassian :: http://www.atlassian.com
Supporting YOUR J2EE World