I found out today that you're not supposed to initialize
bean instances in the ejbFindByPrimaryKey method at all.
I too was under the impression that the instance executing the
ejbFind method is the one going to serve the business requests,
but this turns out to be not the case. The finder bean stays
in the pool, and a NEW instance is created that will serve the
requests. Hence the call to ejbLoad. So just take your refresh out
of the ejbFind method, it shouldn't be there.

Frank Sauer
The Technical Resource Connection
a wholly owned subsidiary of Perot Systems
mailto:[EMAIL PROTECTED]
http://www.trcinc.com

-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Joel Nylund
Sent: Wednesday, August 11, 1999 10:23 AM
To: [EMAIL PROTECTED]
Subject: ejbLoad() any way to control


(Im using Bean Managed Persistence)

I noticed that examples from my vendor, and a couple of books I have
read show examples of BMP Entity beans that look like:

ejbFindByPrimaryKey(MyPK aPK)
{
    refresh(aPK);
}

refresh(pk)
{
  select * from table x
  load all the data into the instance
}

lets also assume I have a method:
ejbLoad()
{
 refresh(pk)
}

What I observe happening in my container when a client calls findByX is:

findByX()
refresh()
ejbActivate()

but before I can call another method on the bean, the container calls:
ejbLoad() (which then calls refresh() )

So I in effect get 2 selects for the client method call:

clientCall
{
myBean = home.findByX("foo");
myBean.doSomething();
}

This seems very inefficient. I think if I wrap the whole call in a
transaction then It would make me only have 1 select. But I dont want a
transaction for read only stuff.

I guess the main comment is there is a way to tell the container you
know better on a save by using a dirty flag, but there doesnt seem to be
a way to do this with the load.

I would really like to say, hey if this is all coming from one client
context, then dont call load on each call (even if im not in a
transaction).

any ideas on how to do this the most efficient way?

thanks
Joel

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to